Nagios stop working

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.
rbizzell39
Posts: 112
Joined: Thu Dec 17, 2015 1:24 pm

Nagios stop working

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios stop working

Post by mcapra »

Can you share the output of:

Code: Select all

ls -al /etc/nagios/
Former Nagios employee
https://www.mcapra.com/
rbizzell39
Posts: 112
Joined: Thu Dec 17, 2015 1:24 pm

Re: Nagios stop working

Post 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
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios stop working

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
rbizzell39
Posts: 112
Joined: Thu Dec 17, 2015 1:24 pm

Re: Nagios stop working

Post 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
rbizzell39
Posts: 112
Joined: Thu Dec 17, 2015 1:24 pm

Re: Nagios stop working

Post 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
rbizzell39
Posts: 112
Joined: Thu Dec 17, 2015 1:24 pm

Re: Nagios stop working

Post by rbizzell39 »

I have been using the one underneath /usr/local/nagios
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios stop working

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
rbizzell39
Posts: 112
Joined: Thu Dec 17, 2015 1:24 pm

Re: Nagios stop working

Post by rbizzell39 »

NagiosCfgFile=${prefix}/etc/nagios.cfg

Is this the line that I need to change /usr/local/nagios/etc/nagios.cfg
rbizzell39
Posts: 112
Joined: Thu Dec 17, 2015 1:24 pm

Re: Nagios stop working

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