In fact, looking in to this a bit more I think there is a more serious bug in the init script. A reload appears to to remove the PID file all together causing the issue that Kevin Lamontagne also reported.
root@noc:/var/run/nagios2# /etc/init.d/nagios2 start
* Starting nagios2 monitoring daemon nagios2 [ OK ]
root@noc:/var/run/nagios2# ls -l
total 4
-rw-r--r-- 1 nagios nagios 6 2007-12-17 12:48 nagios2.pid
root@noc:/var/run/nagios2# /etc/init.d/nagios2 reload
* Reloading nagios2 monitoring daemon configuration files nagios2 [ OK ]
root@noc:/var/run/nagios2# ls -l nagios2.pid
ls: nagios2.pid: No such file or directory
Note that a reload has removed the nagios2.pid file but the nagios2 process is still running.
If you then try another reload, the init script can't find the nagios2.pid file so assumes it's not running but a ps says otherwise:
root@noc:/var/run/nagios2# /etc/init.d/nagios2 reload
* Reloading nagios2 monitoring daemon configuration files nagios2 * Not running. [fail]
root@noc:/var/run/nagios2# ls -l nagios2.pid
ls: nagios2.pid: No such file or directory
root@noc:/var/run/nagios2# ps aux | grep nagios
nagios 19207 0.1 0.1 23628 2124 ? SNsl 12:50 0:00 /usr/sbin/nagios2 -d /etc/nagios2/nagios.cfg
Now there are two scenarios. Firstly, if you didn't check with ps and assumed the init script is correct (i..e nagios2 isn't running when it actually is) and start nagios2, you end up with two nagios2 processes running. Or if you try to first run "/etc/init.d/nagios2 stop" this won't kill the process because there's no PID file (remember it was removed by "/etc/init.d/nagios2 reload") and then assume it has been stopped and start it again, you once again end up with two nagios2 processes running.
In fact, looking in to this a bit more I think there is a more serious bug in the init script. A reload appears to to remove the PID file all together causing the issue that Kevin Lamontagne also reported.
root@noc: /var/run/ nagios2# /etc/init.d/nagios2 start /var/run/ nagios2# ls -l
* Starting nagios2 monitoring daemon nagios2 [ OK ]
root@noc:
total 4
-rw-r--r-- 1 nagios nagios 6 2007-12-17 12:48 nagios2.pid
root@noc: /var/run/ nagios2# /etc/init.d/nagios2 reload /var/run/ nagios2# ls -l nagios2.pid
* Reloading nagios2 monitoring daemon configuration files nagios2 [ OK ]
root@noc:
ls: nagios2.pid: No such file or directory
Note that a reload has removed the nagios2.pid file but the nagios2 process is still running.
If you then try another reload, the init script can't find the nagios2.pid file so assumes it's not running but a ps says otherwise:
root@noc: /var/run/ nagios2# /etc/init.d/nagios2 reload
[fail] /var/run/ nagios2# ls -l nagios2.pid /var/run/ nagios2# ps aux | grep nagios nagios. cfg
* Reloading nagios2 monitoring daemon configuration files nagios2 * Not running.
root@noc:
ls: nagios2.pid: No such file or directory
root@noc:
nagios 19207 0.1 0.1 23628 2124 ? SNsl 12:50 0:00 /usr/sbin/nagios2 -d /etc/nagios2/
Now there are two scenarios. Firstly, if you didn't check with ps and assumed the init script is correct (i..e nagios2 isn't running when it actually is) and start nagios2, you end up with two nagios2 processes running. Or if you try to first run "/etc/init. d/nagios2 stop" this won't kill the process because there's no PID file (remember it was removed by "/etc/init. d/nagios2 reload") and then assume it has been stopped and start it again, you once again end up with two nagios2 processes running.
root@noc: /var/run/ nagios2# ls -l nagios2.pid /var/run/ nagios2# /etc/init.d/nagios2 stop /var/run/ nagios2# ps aux | grep nagios2 nagios. cfg /var/run/ nagios2# /etc/init.d/nagios2 start /var/run/ nagios2# ps aux | grep nagios nagios. cfg nagios. cfg /var/run/ nagios2# cat nagios2.pid /var/run/ nagios2# /etc/init.d/nagios2 stop /var/run/ nagios2# ps aux | grep nagios2 nagios. cfg
ls: nagios2.pid: No such file or directory
root@noc:
* Stopping nagios2 monitoring daemon nagios2 [ OK ]
root@noc:
nagios 19207 0.0 0.6 28688 8116 ? SNsl 12:50 0:00 /usr/sbin/nagios2 -d /etc/nagios2/
root@noc:
* Starting nagios2 monitoring daemon nagios2 [ OK ]
root@noc:
nagios 19207 0.0 0.6 28688 8116 ? SNsl 12:50 0:00 /usr/sbin/nagios2 -d /etc/nagios2/
nagios 19787 1.0 0.1 22432 1636 ? SNsl 12:57 0:00 /usr/sbin/nagios2 -d /etc/nagios2/
root@noc:
19787
root@noc:
* Stopping nagios2 monitoring daemon nagios2 [ OK ]
root@noc:
nagios 19207 0.0 0.6 28688 8116 ? SNsl 12:50 0:00 /usr/sbin/nagios2 -d /etc/nagios2/
I hope this makes sense?