Page 1 of 1

Nagios process failed to auto-start during system boot

Posted: Mon May 04, 2015 8:31 am
by lsazzad
After each time when i restart my system, i have to restart the Nagios process manually. I need to add enable this can be done automatically? Please suggest step by step::

* I am using Ubuntu 15.04 (GNU/Linux 3.16.0-36-generic x86_64)

Re: Nagios process failed to auto-start during system boot

Posted: Mon May 04, 2015 9:12 am
by ssax
Which version of Nagios are you trying to install? Are you following a guide for the install (provide the link) or how did you install it?

Re: Nagios process failed to auto-start during system boot

Posted: Tue May 05, 2015 5:26 am
by lsazzad
I am using nagios 4.0.8 Version. I just followed bellow link to install NAGIOS::

http://sharadchhetri.com/2014/08/25/ins ... 14-04-lts/

Re: Nagios process failed to auto-start during system boot

Posted: Tue May 05, 2015 9:21 am
by jdalrymple
By what means are you starting the process?

Are you calling the binary or are you using an init script? It looks like SUSE recently quit working with our init scripts altogether and perhaps you're in the same boat.

Re: Nagios process failed to auto-start during system boot

Posted: Tue May 05, 2015 9:36 am
by lsazzad
After each time my server restarted i need to manually restart the process using following command:

Code: Select all

sudo service nagios restart
As per my guide line there is a script at
/etc/init/nagios.conf

Code: Select all

description     "nagios 4.x core"
 
start on filesystems
stop on runlevel [1246]
 
respawn
 
setuid nagios
setgid nagcmd
console log
 
script
        exec /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
end script
I beleive this script is no longer working. What should modification can do the resoluation? Or please do suggest some possible way to fix it.

Re: Nagios process failed to auto-start during system boot

Posted: Tue May 05, 2015 10:00 am
by ssax
Here's what I had to do to get it running:

Create /etc/systemd/system/nagios.service with the contents below:

Code: Select all


[Unit]
Description=Nagios
BindTo=network.target

[Install]
WantedBy=multi-user.target

[Service]
User=nagios
Group=nagios
Type=simple
ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
Then:

Code: Select all

sudo systemctl enable /etc/systemd/system/nagios.service

Re: Nagios process failed to auto-start during system boot

Posted: Wed May 06, 2015 1:04 am
by lsazzad
Thanks a lot. It works. Would you mind to describe me a little bit about this steps? It would help me to make similiar script for my other services as well.

Again thanks a lot!

Admin can close this thread! :D :D :D

Re: Nagios process failed to auto-start during system boot

Posted: Wed May 06, 2015 10:26 am
by jdalrymple
I'll expand on ssax's answer a bit. Here is some a more thorough systemd script:

Code: Select all

[Unit]
Description=Nagios Core Monitoring Daemon
After=network.target

[Service]
User=nagios
Group=nagios
Type=forking
ExecStart=/usr/lib/systemd/scripts/nagios start
ExecStop=/usr/lib/systemd/scripts/nagios stop
ExecReload=/usr/lib/systemd/scripts/nagios reload

[Install]
WantedBy=multi-user.target
It actually leverages the logic we have built into the original init script so you can use it to reload your daemon after you've changed configs ... safely. You will need to relocate /etc/init.d/nagios to the path shown (/usr/lib/systemd/scripts/).

Documentation on creating these files is here:
http://www.freedesktop.org/software/sys ... rvice.html