Bug 223087 - [PATCH] net-mgmt/nagios4: use same lock_file as in nagios.in
Summary: [PATCH] net-mgmt/nagios4: use same lock_file as in nagios.in
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Mathieu Arnold
URL: https://reviews.freebsd.org/D12716
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-10-18 12:14 UTC by Vinícius Zavam
Modified: 2017-11-07 15:49 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (mat)


Attachments
[PATCH] net-mgmt/nagios4: use same lock_file as in nagios.in (r449682) (645 bytes, patch)
2017-10-18 12:14 UTC, Vinícius Zavam
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vinícius Zavam freebsd_committer freebsd_triage 2017-10-18 12:14:30 UTC
Created attachment 187271 [details]
[PATCH] net-mgmt/nagios4: use same lock_file as in nagios.in (r449682)

The current patch updates "net-mgmt/nagios4/Makefile" (r449682) in order to use the set the Nagios' lock_file used by its rc script. Without the patch, a new setup of Nagios under FreeBSD fails.

    # uname -iUKa
    FreeBSD freebsd11-nagios4 11.1-RELEASE-p1 FreeBSD 11.1-RELEASE-p1 #0: Wed Aug  9 11:55:48 UTC 2017     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64 GENERIC 1101001 1101001
    
    # env ASSUME_ALWAYS_YES=yes pkg bootstrap
    # pkg install -y nagios4
    
    # cd /usr/local/etc/nagios/
    # mv cgi.cfg-sample cgi.cfg
    # mv nagios.cfg-sample nagios.cfg
    # mv resource.cfg-sample resource.cfg
    # cd objects/
    # mv commands.cfg-sample commands.cfg
    # mv contacts.cfg-sample contacts.cfg
    # mv localhost.cfg-sample localhost.cfg
    # mv printer.cfg-sample printer.cfg
    # mv switch.cfg-sample switch.cfg
    # mv templates.cfg-sample templates.cfg
    # mv timeperiods.cfg-sample timeperiods.cfg
    # mv windows.cfg-sample windows.cfg

    # ls -laRsh /usr/local/etc/nagios/ | grep -i sampl | wc
       0       0       0
    # ls -laRsh /usr/local/etc/nagios/ | grep -i cfg | wc
      11     110     687

    # sysrc nagios_enable=YES
    nagios_enable:  -> YES
    
    # service nagios start
    Performing sanity check of nagios configuration: OK
    Starting nagios.
    /usr/local/etc/rc.d/nagios: WARNING: failed to start nagios
    
    # cat /var/spool/nagios/nagios.log
    [1508320974] Failed to obtain lock on file /var/run/nagios.lock: Permission denied
    [1508320974] Bailing out due to errors encountered while attempting to daemonize... (PID=787)
Comment 1 Vinícius Zavam freebsd_committer freebsd_triage 2017-10-18 12:25:28 UTC
Aplied patch in a jail should work as follows.

root@zim:~ # jexec 11amd64-svn-n env -i TERM=$TERM /usr/bin/login -fp root

root@11amd64-svn:~ # uname -a
FreeBSD 11amd64-svn 11.1-RELEASE-p1 FreeBSD 11.1-RELEASE-p1 amd64

root@11amd64-svn:~ # pkg info -x nagios
nagios-plugins-2.2.1_5,1
nagios4-4.3.4_1,1

root@11amd64-svn:~ # cd /usr/local/etc/nagios/
root@11amd64-svn:/usr/local/etc/nagios # mv cgi.cfg-sample cgi.cfg
root@11amd64-svn:/usr/local/etc/nagios # mv nagios.cfg-sample nagios.cfg
root@11amd64-svn:/usr/local/etc/nagios # mv resource.cfg-sample resource.cfg
root@11amd64-svn:/usr/local/etc/nagios # cd objects/
root@11amd64-svn:/usr/local/etc/nagios/objects # mv commands.cfg-sample commands.cfg
root@11amd64-svn:/usr/local/etc/nagios # mv contacts.cfg-sample contacts.cfg
root@11amd64-svn:/usr/local/etc/nagios # mv localhost.cfg-sample localhost.cfg
root@11amd64-svn:/usr/local/etc/nagios # mv printer.cfg-sample printer.cfg
root@11amd64-svn:/usr/local/etc/nagios # mv switch.cfg-sample switch.cfg
root@11amd64-svn:/usr/local/etc/nagios # mv templates.cfg-sample templates.cfg
root@11amd64-svn:/usr/local/etc/nagios # mv timeperiods.cfg-sample timeperiods.cfg
root@11amd64-svn:/usr/local/etc/nagios # mv windows.cfg-sample windows.cfg

root@11amd64-svn:/usr/local/etc/nagios/objects # sysrc nagios_enable=YES
nagios_enable:  -> YES

root@11amd64-svn:/usr/local/etc/nagios/objects # service nagios start
Performing sanity check of nagios configuration: OK
Starting nagios.

root@11amd64-svn:/usr/local/etc/nagios/objects # cat /var/spool/nagios/nagios.log 
[1508329034] Nagios 4.3.4 starting... (PID=21839)
[1508329034] Local time is Wed Oct 18 12:17:14 UTC 2017
[1508329034] LOG VERSION: 2.0
[1508329034] qh: Socket '/var/spool/nagios/rw/nagios.qh' successfully initialized
[1508329034] qh: core query handler registered
[1508329034] nerd: Channel hostchecks registered successfully
[1508329034] nerd: Channel servicechecks registered successfully
[1508329034] nerd: Channel opathchecks registered successfully
[1508329034] nerd: Fully initialized and ready to rock!
[1508329034] wproc: Successfully registered manager as @wproc with query handler
[1508329034] wproc: Registry request: name=Core Worker 21840;pid=21840
[1508329034] wproc: Registry request: name=Core Worker 21844;pid=21844
[1508329034] wproc: Registry request: name=Core Worker 21842;pid=21842
[1508329034] wproc: Registry request: name=Core Worker 21845;pid=21845
[1508329034] wproc: Registry request: name=Core Worker 21841;pid=21841
[1508329034] wproc: Registry request: name=Core Worker 21843;pid=21843
[1508329034] Successfully launched command file worker with pid 21846
Comment 2 Vinícius Zavam freebsd_committer freebsd_triage 2017-10-18 12:34:14 UTC
Added to Phabricator (https://reviews.freebsd.org/D12716).
Comment 3 Vinícius Zavam freebsd_committer freebsd_triage 2017-10-19 07:36:35 UTC
(In reply to Vinícius Zavam from comment #2)

More details about what this patch does, you can find on review D12716.
Comment 4 Vinícius Zavam freebsd_committer freebsd_triage 2017-11-03 16:17:38 UTC
- Problem Description

There's a conflict between the lockfile used on the installed nagios.cfg sample, and the Nagios' rc script (etc/rc.d/nagios).
They are using a different lockfile, making it impossible to the Nagios' user/daemon to identify the running process, and properly lock it.

- Suggestion to Solve the Problem

Build Nagios using " --with-lockfile=${NAGIOSDIR}/nagios.lock "
Doing it will bring the same lockfile to either the rc scrip t and the installed nagios.cfg sample.
Comment 5 commit-hook freebsd_committer freebsd_triage 2017-11-07 15:49:27 UTC
A commit references this bug:

Author: mat
Date: Tue Nov  7 15:47:55 UTC 2017
New revision: 453665
URL: https://svnweb.freebsd.org/changeset/ports/453665

Log:
  Set the correct lockfile in nagios.cfg-sample.

  PR:		223087
  Submitted by:	Vin?cius Zavam
  Sponsored by:	Absolight

Changes:
  head/net-mgmt/nagios4/Makefile