Page 1 of 1

service nagios reload not existent

Posted: Thu Sep 22, 2016 10:00 am
by Pitone_Maledetto
Hi all,
I have installed the latest version of Nagios 4.2.1 on Debian Jessie.
All is fine but the service is missing the reload option.

root@nagios-01: service nagios reload
Usage: /etc/init.d/nagios {start|stop|status|restart|try-restart|force-reload}

Now this is my nagios.service file in /run/systemd/generator.late/nagios.service

Code: Select all

# Automatically generated by systemd-sysv-generator

[Unit]
SourcePath=/etc/init.d/nagios
Description=LSB: Example initscript
Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target
After=remote-fs.target systemd-journald-dev-log.socket
Conflicts=shutdown.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
SysVStartPriority=3
ExecStart=/etc/init.d/nagios start
ExecStop=/etc/init.d/nagios stop
and this is my /etc/init.d/nagios file

Code: Select all

#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:          skeleton
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.  This example start a
#                    single forking daemon capable of writing a pid
#                    file.  To get other behavoirs, implemend
#                    do_start(), do_stop() or other functions to
#                    override the defaults in /lib/init/init-d-script.
### END INIT INFO

# Author: my name <[email protected]>
#
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.

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
Can anyone please point me to the right direction in order to solve the issue?
Thanks

Re: service nagios reload not existent

Posted: Thu Sep 22, 2016 2:32 pm
by rkennedy
The issue is your init script is for systemd and using the skeleton base. When you are running through the install process of Nagios, you'll at one point run make install-init. This will create the correct init file for you.

See this document for reference - https://assets.nagios.com/downloads/nag ... Source.pdf

Here is what you'll need to run (might need to modify configure command based on your system) -

Code: Select all

cd /tmp
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.0.tar.gz
tar -zxvf nagios-4.2.0.tar.gz
cd nagios-4.2.0/
./configure --with-command-group=nagcmd --with-mail=/usr/bin/sendmail --with-httpd-conf=/etc/apache2/
make install-init
cat /etc/init.d/nagios
service nagios reload

Re: service nagios reload not existent

Posted: Fri Sep 23, 2016 2:47 am
by Pitone_Maledetto
Thanks rkennedy,
re running the make install-init solved the issue.
During the installation I followed the document that you have pointed me to and I have realized my mistake.
Since the guide does not provide Debian instructions I went with the closest one: For Ubuntu users using systemd thinking that systemd was used by default in Debian.
Therefore:

Code: Select all

sudo cp /etc/init.d/skeleton /etc/init.d/nagios
sudo vi /etc/init.d/nagios (and add the following lines)
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
which replaced the whole content of /etc/init.d/nagios

Thank you again for your help.
Happy Nagiosing!

Re: service nagios reload not existent

Posted: Fri Sep 23, 2016 10:34 am
by rkennedy
I figured that's what happened, I did the same thing brainlessly not thinking on a test machine, and sure enough walked myself backwards through it to solve this one.

Going to mark this one as resolved, and close it up!