Nagios 4: Can’t open /etc/rc.d/init.d/functions

Nicolargo picture Nicolargo · Oct 26, 2013 · Viewed 23.2k times · Source

I just upgrade my Nagios server to the latest version (4.0.1) on my Debian 7 system. When i start the daemon, i have the following error:

# /etc/init.d/nagios start
/etc/init.d/nagios: 20: .: Can't open /etc/rc.d/init.d/functions

The /etc/rc.d/init.d/functions did not exist on my Debian system (and also on my Ubuntu 12.04 workstation).

What can i do to solve this issue ?

=== Update:

Just hack the startup script with the following command line:

sudo apt-get install daemon
sudo sed -i 's/^\.\ \/etc\/rc.d\/init.d\/functions$/\.\ \/lib\/lsb\/init-functions/g' /etc/init.d/nagios
sudo sed -i 's/status\ /status_of_proc\ /g' /etc/init.d/nagios
sudo sed -i 's/daemon\ --user=\$user\ \$exec\ -ud\ \$config/daemon\ --user=\$user\ --\ \$exec\ -d\ \$config/g' /etc/init.d/nagios
sudo sed -i 's/\/var\/lock\/subsys\/\$prog/\/var\/lock\/\$prog/g' /etc/init.d/nagios
sudo service nagios start

Works fine on my Debian server.

Answer

Viceman picture Viceman · Jan 24, 2014

You can simply write your own init script. Copy /etc/init.d/skeleton to /etc/init.d/nagios and fill in the values in that file:

DESC="Nagios"
NAME=nagios
DAEMON=/usr/local/nagios/bin/$NAME
DAEMON_ARGS="-d /usr/local/nagios/etc/nagios.cfg"
PIDFILE=/usr/local/nagios/var/$NAME.lock

I also commented these lines:

#[ -r /etc/default/$NAME ] && . /etc/default/$NAME

and

       #start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
       #       || return 1

Don't forget to chmod +x /etc/init.d/nagios.

Have fun.