When attempting to stop or restart Nagios on CentOS I was receiving the below error. This has been an issue for me for quite some time however I was to lazy to even put a patch in place and always just would kill the Nagios processes by hand. Tonight I was modifying some Nagios configuration files and got enoyed enough that I first attempted to upgrade Nagios to the latest available on the rpmforge repo and when the problem still existed I decided to figure out a solution.
Error: Stopping nagios: kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec … or kill -l [sigspec]
Commands Used To Generate Error:
- [root@server run]# /etc/init.d/nagios stop
- Stopping nagios: kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
- done.
- [root@server run]# /etc/init.d/nagios restart
- Running configuration check...done.
- Stopping nagios: kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
- done.
- Starting nagios: done.
Anyhow the quick solution is to modify the /etc/init.d/nagios file. Using “/etc/init.d/nagios restart” will still be broken because it uses HUP instead of terminating the service. For now though you can use stop and start and at least that is less annoying than having to manually kill the processes each time. You need to modify the killproc_nagios function which located around line 64 in /etc/init.d/nagios.
Original killproc_nagios Statement:
- killproc_nagios ()
- {
- kill $2 $NagiosPID
- }
New killproc_nagios Statement:
- killproc_nagios ()
- {
- #kill $2 $NagiosPID
- killall nagios
- }
That is all you need to do. You should not be able to stop and start nagios with the nagios init.d script.
Erm…just set the right location for the lockfile nagios.lock (by default its /usr/local/nagios/var which is taken by the init-script. Otherwise you cannot use reload or the “service” cmd to reload or restart the service.
Oh, I forgot, of course it has to be defined in your global nagios.cfg.
Hello TM,
Thanks for taking the time to first post the above information and second to follow up. Also I wanted to note the nagios.cfg configuration option for the lock file. The syntax is as follows for anyone that runs across this article.
lock_file=
or
lock_file=/tmp/nagios.lock
Of course if you have been running without that configuration option you will want to shutdown Nagios, remove the current lock file, and restart Nagios once the above option has been added to nagios.cfg.
Thanks!
alex