Nagios process failed to auto-start during system boot

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
lsazzad
Posts: 72
Joined: Tue Apr 07, 2015 6:52 am
Location: ​Osnabrück, Deutschland
Contact:

Nagios process failed to auto-start during system boot

Post 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)
Regards
Sazzad
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

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

Post 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?
lsazzad
Posts: 72
Joined: Tue Apr 07, 2015 6:52 am
Location: ​Osnabrück, Deutschland
Contact:

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

Post 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/
Regards
Sazzad
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

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

Post 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.
lsazzad
Posts: 72
Joined: Tue Apr 07, 2015 6:52 am
Location: ​Osnabrück, Deutschland
Contact:

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

Post 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.
Regards
Sazzad
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

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

Post 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
lsazzad
Posts: 72
Joined: Tue Apr 07, 2015 6:52 am
Location: ​Osnabrück, Deutschland
Contact:

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

Post 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
Regards
Sazzad
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

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

Post 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
Locked