Nagios not starting after boot

debian-wheezyinit.dnagios

I have a small Nagios 4.1.1 install I just completed. It's running on a Raspberry Pi using Raspbian. Checks out okay, and when I start it manually using /etc/init.d/nagios start it works fine.

I've always told my debian systems to start things on system boot by doing something like this: ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios I can see the symbolic link is created successfully.

But, it doesn't fire off at boot time. I can run the startup scripts after the system is up by doing /etc/rcS.d/S99nagios start so I know (/think) the symbolic link is good. When the server comes up, Apache is running, and the Nagios page is up, but the home page says "Unable to get process status", which is expected when the nagios service isn't running. Is there any way to look at startup logs to see if it's trying, or is there a better way to get it to start on boot?

Update:
I ran update-rc.d and it gives me this:

update-rc.d: using dependency based boot sequencing
update-rc.d: warning: default start runlevel arguments (2 3 4 5) do not match resize2fs_once Default-Start values (2 3 4 5 S)
update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match resize2fs_once Default-Stop values (none)
insserv: Script nagios is broken: incomplete LSB comment.
insserv: missing `Default-Start:'  entry: please add even if empty.
insserv: missing `Default-Stop:'   entry: please add even if empty.
insserv: Script nagios is broken: incomplete LSB comment.
insserv: missing `Default-Start:'  entry: please add even if empty.
insserv: missing `Default-Stop:'   entry: please add even if empty.
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `nagios'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `nagios'

I really have never seen this, and don't know what to do, but it has to be related.

Update 2:
Doing some reading, it seems this may be related to the way the init.d scripts are formatted. If that's the case, it's likely that others are having this issue as well, and it wouldn't be the first time init.d scripts caused problems for Nagios on Debian based systems. I'm going to close this and open a ticket on the Nagios bugtracker.

Best Answer

This seems to be a problem with init.d script's formatting. This solved the issue for me:

First, edit the nagios init.d script:

nano /etc/init.d/nagios

Replace the block that starts and ends like this:

### BEGIN INIT INFO
#
# stuff in here
#
### END INIT INFO

With this:

### BEGIN INIT INFO
# Provides: nagios
# Required-Start: $local_fs $syslog $network
# Required-Stop: $local_fs $syslog $network
# Short-Description: Start and Stop Nagios monitoring server
# Description: Nagios is is a service monitoring system
# Default-Start: start
# Default-Stop: stop
### END INIT INFO

From here

Then run:

sudo update-rc.d nagios defaults

You'll get some warnings that can safely be ignored. For instance:

update-rc.d: warning: default start runlevel arguments (2 3 4 5) do not match nagios Default-Start values (start)

Reboot and check. Mine now comes up automatically.

So, it appears the overall formatting agrees with the required standard, just the INIT block is missing some things. I do prefer this method to using someone else's init.d file for Nagios, because I believe the developers probably maintain that script better than I could. One thing to note is that if you ever update Nagios from source, and you run make install-init it will overwrite this file, and you will have to do this again. The alternative is to install what you need, leaving out the init script.

Related Topic