Page 1 of 4

Nagios stop working

Posted: Thu Nov 10, 2016 3:44 pm
by rbizzell39
I installed NRPE and had that up and running as well as Nagios I was testing NRPE and it was up listening on the ports an I received a socket error when I was testing out communication with one of my windows server and now nagios won't start.

Error: Cannot open main configuration file '/etc/nagios/nagios.cfg' for reading!
Error processing main config file!
nagios.service: control process exited, code=exited status=1
Failed to start Nagios Network Monitoring.
Unit nagios.service entered failed state.
Time has been changed
Started Session 17502 of user root.
systemd: Starting Session 17502 of user root.
systemd: Created slice user-987.slice.
systemd: Starting user-987.slice.
Started Session 17501 of user cacti.
Starting Session 17501 of user cacti.
Removed slice user-987.slice.
Stopping user-987.slice.
Time has been changed

Re: Nagios stop working

Posted: Thu Nov 10, 2016 5:48 pm
by mcapra
Can you share the output of:

Code: Select all

ls -al /etc/nagios/

Re: Nagios stop working

Posted: Fri Nov 11, 2016 9:30 am
by rbizzell39
ls -al /etc/nagios/
total 12
drwxrwxr-x 3 root root 20 Nov 10 11:31 .
drwxr-xr-x. 144 root root 8192 Nov 10 15:48 ..
drwxr-x--- 2 root nagios 26 Nov 10 11:31 objects

Re: Nagios stop working

Posted: Fri Nov 11, 2016 12:15 pm
by tgriep
It looks like the nagios.cfg file is not in that folder.
Was it moved to a different folder?
You can run the following to find the folder the nagios.cfg is is unless is was deleted.

Code: Select all

find / -name nagios.cfg

Re: Nagios stop working

Posted: Fri Nov 11, 2016 12:26 pm
by rbizzell39
not sure what happen but I thought everything was under /usr/local/nagios and I was following the guide to install NRPE separately which I wouldn't have thought would have modified my nagios.cfg

Re: Nagios stop working

Posted: Fri Nov 11, 2016 12:27 pm
by rbizzell39
/home/rbizzell/Downloads/nagios-4.2.1/sample-config/nagios.cfg
/home/rbizzell/Downloads/nagios-4.2.1/t-tap/smallconfig/nagios.cfg
/home/rbizzell/Downloads/nagios-4.2.1/t/etc/nagios.cfg
find: ‘/run/user/1000/gvfs’: Permission denied
/root/nagios-4.0.8/sample-config/nagios.cfg
/root/nagios-4.0.8/t-tap/smallconfig/nagios.cfg
/root/nagios-4.0.8/t/etc/nagios.cfg
/root/nagios/etc/nagios.cfg
/usr/local/nagios/etc/nagios.cfg

Re: Nagios stop working

Posted: Fri Nov 11, 2016 12:47 pm
by rbizzell39
I have been using the one underneath /usr/local/nagios

Re: Nagios stop working

Posted: Fri Nov 11, 2016 1:11 pm
by tgriep
The nagios init script on your system is looking for the nagios.cfg file in this location

Code: Select all

/etc/nagios/nagios.cfg
and it needs to be updated to this location and that should fix it for you.

Code: Select all

/usr/local/nagios/etc/nagios.cfg
On a Centos / Redhat system, the init script is located here

Code: Select all

/etc/init.d/nagios
Take a look at it and adjust it to the correct path.

Re: Nagios stop working

Posted: Fri Nov 11, 2016 1:37 pm
by rbizzell39
NagiosCfgFile=${prefix}/etc/nagios.cfg

Is this the line that I need to change /usr/local/nagios/etc/nagios.cfg

Re: Nagios stop working

Posted: Fri Nov 11, 2016 1:49 pm
by rbizzell39
I made the changes to the init file and received this error

systemctl start nagios.service
Job for nagios.service failed because the control process exited with error code. See "systemctl status nagios.service" a nd "journalctl -xe" for details.
[root@splab-nagios init.d]# systemctl status nagios.service
● nagios.service - Nagios Network Monitoring
Loaded: loaded (/usr/lib/systemd/system/nagios.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2016-11-11 13:48:45 EST; 13s ago
Docs: https://www.nagios.org/documentation/
Process: 12074 ExecStartPre=/usr/sbin/nagios -v /etc/nagios/nagios.cfg (code=exited, status=1/FAILURE)

Nov 11 13:48:45 splab-nagios systemd[1]: Starting Nagios Network Monitoring...
Nov 11 13:48:45 splab-nagios systemd[1]: nagios.service: control process exited, code=exited status=1
Nov 11 13:48:45 splab-nagios systemd[1]: Failed to start Nagios Network Monitoring.
Nov 11 13:48:45 splab-nagios systemd[1]: Unit nagios.service entered failed state.
Nov 11 13:48:45 splab-nagios systemd[1]: nagios.service failed.