Error: Could not read host and service status information!

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.
tr53
Posts: 6
Joined: Thu Oct 24, 2019 10:01 am

Error: Could not read host and service status information!

Post by tr53 »

Hi,

I have a below error in nagios and I wonder if someone could help.

Code: Select all

Whoops!
Error: Could not read host and service status information!

The most common cause of this error message (especially for new users), is the fact that Nagios is not actually running. If Nagios is indeed not running, this is a normal error message. It simply indicates that the CGIs could not obtain the current status of hosts and services that are being monitored. If you've just installed things, make sure you read the documentation on starting Nagios.

Some other things you should check in order to resolve this error include:

Check the Nagios log file for messages relating to startup or status data errors.
Always verify configuration options using the -v command-line option before starting or restarting Nagios!
Make sure you read the documentation on installing, configuring and running Nagios thoroughly before continuing. If all else fails, try sending a message to one of the mailing lists. More information can be found at http://www.nagios.org.
I ran

Code: Select all

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
which gave me one error, and then I stupidly (too quickly and not checking it) ran

Code: Select all

sudo /etc/rc.d/init.d/nagios reload
The error was:

Code: Select all

Error: The description string for service 'Free Memory, less than 1.5 eq Critical' on host 'pfsense' contains one or more illegal characters.
Basically a dot or a comma which I now removed.

Code: Select all

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
doesn't give me any errors now, but nagios still can't read host and service status information.

Nagios is running

Code: Select all

ps -ef | grep nagios
nagios   15391     1  0 15:33 ?        00:00:00 /usr/sbin/nagios -d /etc/nagios/nagios.cfg
root     15540 15526  0 15:40 pts/0    00:00:00 grep --color=auto nagios
I can access the main page, and MRTG graphs, but any other page is giving me

Code: Select all

Whoops!
error.

Debug is set to zero but I can change it and maybe get some info?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Error: Could not read host and service status informatio

Post by scottwilkerson »

Did you restart nagios after making the correction?

Did you check the nagios.log for startup errors?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
tr53
Posts: 6
Joined: Thu Oct 24, 2019 10:01 am

Re: Error: Could not read host and service status informatio

Post by tr53 »

Hi Scott,

Yes I did restart nagios using

Code: Select all

sudo /etc/rc.d/init.d/nagios reload
and also by restarting the server.

Code: Select all

cat /var/log/nagios/nagios.log
[1571987038] Caught SIGTERM, shutting down...
[1571987038] Successfully shutdown... (PID=15391)
[1571987089] Nagios 3.5.1 starting... (PID=2749)
[1571987089] Local time is Fri Oct 25 07:04:49 UTC 2019
[1571987089] LOG VERSION: 2.0
[1571987089] Finished daemonizing... (New PID=2782)
[1571987479] SERVICE NOTIFICATION: nagiosadmin;localhost;Swap Usage;CRITICAL;notify-service-by-email;SWAP CRITICAL - 100% free (0 MB out of 0 MB)
[1571990689] Auto-save of retention data completed successfully.
[1571990769] SERVICE NOTIFICATION: nagiosadmin;localhost;HTTP;WARNING;notify-service-by-email;HTTP WARNING: HTTP/1.1 403 Forbidden - 5173 bytes in 0.001 second response time
[1571991079] SERVICE NOTIFICATION: nagiosadmin;localhost;Swap Usage;CRITICAL;notify-service-by-email;SWAP CRITICAL - 100% free (0 MB out of 0 MB)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Error: Could not read host and service status informatio

Post by scottwilkerson »

Can you show the output of the following

Code: Select all

grep nag /etc/group
getenforce
ls -al /usr/local/nagios/var
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
tr53
Posts: 6
Joined: Thu Oct 24, 2019 10:01 am

Re: Error: Could not read host and service status informatio

Post by tr53 »

Hi,

Code: Select all

$ grep nag /etc/group
nagios:x:497:apache

$ getenforce
Disabled

$ ls -al /usr/local/nagios/var
total 848
drwxrwxr-x 5 nagios nagios   4096 Oct 24 14:48 .
drwxr-xr-x 9 root   root     4096 Jul 21  2016 ..
drwxrwxr-x 2 nagios nagios  61440 Oct 23 23:59 archives
-rw-r--r-- 1 nagios nagios     34 Aug 21  2017 nagios.configtest
-rw-r--r-- 1 nagios nagios 122382 Oct 24  2016 nagios.debug
-rw-r--r-- 1 nagios nagios      6 Feb 25  2019 nagios.lock
-rw-r--r-- 1 nagios nagios  65710 Oct 24 14:48 nagios.log
-rw-rw-r-- 1 nagios nagios 143365 Dec 19  2016 nagios.tmpo0D4xY
-rw-r--r-- 1 nagios nagios 129701 Oct 24 14:47 objects.cache
-rw-r--r-- 1 nagios nagios 100248 Aug 21  2017 objects.precache
-rw------- 1 nagios nagios 194538 Oct 24 14:48 retention.dat
drwxrwsr-x 2 nagios nagios   4096 Oct 24 14:48 rw
drwxr-xr-x 3 root   root     4096 Jul 21  2016 spool
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Error: Could not read host and service status informatio

Post by scottwilkerson »

Somehow the nagios user isn't part of the nagios group

As root run the following:

Code: Select all

usermod -a -G nagios nagios
also a few permissions don't seem correct

Code: Select all

chown nagios:nagios /usr/local/nagios /usr/local/nagios/var/spool

then restart nagios and remove that really old lock file if it still exists

Code: Select all

service nagios stop
rm -f /usr/local/nagios/var/nagios.lock
service nagios start
Also, I don't see a status.dat file, could be caused by permissions but if the above doesn't work show the output of the following

Code: Select all

grep status_file /usr/local/nagios/etc/nagios.cfg
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
tr53
Posts: 6
Joined: Thu Oct 24, 2019 10:01 am

Re: Error: Could not read host and service status informatio

Post by tr53 »

Hi,

Thank you for this. I applied commands you mentioned but the issue still persist.

Code: Select all

$ sudo usermod -a -G nagios nagios
$ sudo chown nagios:nagios /usr/local/nagios /usr/local/nagios/var/spool
$ sudo service nagios stop
Stopping nagios: done.

$ sudo rm -f /usr/local/nagios/var/nagios.lock

$ sudo service nagios start
Starting nagios: done.

$ ls -al /usr/local/nagios/var
total 844
drwxrwxr-x 5 nagios nagios   4096 Oct 25 14:04 .
drwxr-xr-x 9 nagios nagios   4096 Jul 21  2016 ..
drwxrwxr-x 2 nagios nagios  61440 Oct 23 23:59 archives
-rw-r--r-- 1 nagios nagios     34 Aug 21  2017 nagios.configtest
-rw-r--r-- 1 nagios nagios 122382 Oct 24  2016 nagios.debug
-rw-r--r-- 1 nagios nagios  65710 Oct 24 14:48 nagios.log
-rw-rw-r-- 1 nagios nagios 143365 Dec 19  2016 nagios.tmpo0D4xY
-rw-r--r-- 1 nagios nagios 129701 Oct 24 14:47 objects.cache
-rw-r--r-- 1 nagios nagios 100248 Aug 21  2017 objects.precache
-rw------- 1 nagios nagios 194538 Oct 24 14:48 retention.dat
drwxrwsr-x 2 nagios nagios   4096 Oct 24 14:48 rw
drwxr-xr-x 3 nagios nagios   4096 Jul 21  2016 spool

$ grep nag /etc/group
nagios:x:497:apache,nagios
nagios.cfg point to status.dat

Code: Select all

$ grep status_file /usr/local/nagios/etc/nagios.cfg
status_file=/usr/local/nagios/var/status.dat
but I found it here

Code: Select all

# find . -name status.dat
./var/log/nagios/status.dat
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Error: Could not read host and service status informatio

Post by scottwilkerson »

tr53 wrote:but I found it here

Code: Select all

# find . -name status.dat
./var/log/nagios/status.dat
That is bizarre

Can you show the output of

Code: Select all

ps -ef|grep nagios.cfg
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
tr53
Posts: 6
Joined: Thu Oct 24, 2019 10:01 am

Re: Error: Could not read host and service status informatio

Post by tr53 »

Code: Select all

$ ps -ef|grep nagios.cfg
nagios    8796     1  0 14:04 ?        00:00:01 /usr/sbin/nagios -d /etc/nagios/nagios.cfg
ec2-user  9894  7894  0 15:14 pts/0    00:00:00 grep --color=auto nagios.cfg
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Error: Could not read host and service status informatio

Post by scottwilkerson »

tr53 wrote:

Code: Select all

$ ps -ef|grep nagios.cfg
nagios    8796     1  0 14:04 ?        00:00:01 /usr/sbin/nagios -d /etc/nagios/nagios.cfg
ec2-user  9894  7894  0 15:14 pts/0    00:00:00 grep --color=auto nagios.cfg
Ok, there is a problem here, you somehow have installed both a source install and a packaged (maybe yum/apt) install

So you have one config going off of

Code: Select all

/etc/nagios/nagios.cfg
and another going off of

Code: Select all

/usr/local/nagios/etc/nagios.cfg
You need to determine which set of configs are correct... and I would highly recommend moving them to a new clean install if at all possible as this is going to be really confusing for anyone administering this machine (not to mention the cleanup is going to already get messy)
https://support.nagios.com/kb/article/n ... ce-96.html
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked