Page 1 of 4

Error: Could not read host and service status information!

Posted: Mon Jan 20, 2020 9:43 pm
by buee
Yes, another one of these. I spent about 3 hours today going through the many threads related to this topic and none of them made any forward progress so I'm going go to post and see what happens. The current situation:

When visiting the same URL I've used for years, I get...
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.
Running Nagios Core 3.5.1. Pre flight check says all is well. Nagios is running as the appropriate user and all locations that I've tracked down appear to have the proper permissions. My best guess is a routine upgrade through apt may have broken a dependency of Nagios.

Logs indicate the service appears to be running fine, nothing special when I refresh the page in the logs, even with debug enabled (-1). It is installed through apt if that matters. If I have to compile, that's fine, but really need to keep historical data.

Any ideas?

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

Posted: Tue Jan 21, 2020 2:37 pm
by scottwilkerson
What is the output of the following?

Code: Select all

grep nag /etc/group
and

Code: Select all

grep status_file /path/to/nagios.cfg

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

Posted: Tue Jan 21, 2020 4:39 pm
by buee
scottwilkerson wrote:What is the output of the following?

Code: Select all

grep nag /etc/group
and

Code: Select all

grep status_file /path/to/nagios.cfg

Code: Select all

nagios:x:1001:www-data,nagios
nagcmd:x:1002:nagios,www-data
and

Code: Select all

status_file=/var/cache/nagios3/status.dat
Respectively, also, permissions of /var/cache/nagios3/status.dat:

Code: Select all

-rw-rw-r-- 1 nagios www-data 65K Jan 21 15:38 /var/cache/nagios3/status.dat

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

Posted: Tue Jan 21, 2020 5:10 pm
by Box293
The output looks correct.

What is the URL? Is it a specific service? Is it the landing page?

Is Apache reporting any errors in the logs? Not 100% sure of the log location as you don't state the OS / version.

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

Posted: Tue Jan 21, 2020 6:30 pm
by buee
Box293 wrote:The output looks correct.

What is the URL? Is it a specific service? Is it the landing page?

Is Apache reporting any errors in the logs? Not 100% sure of the log location as you don't state the OS / version.
http://[IP]/nagios3 > Basic Auth pops up, main page loads, but almost everything after that throws the aforementioned error. For example, I usually click on Services and that's my main screen, but I get that error.

I haven't been able to find any Apache errors. Running Ubuntu 16.04 Server at the moment.

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

Posted: Tue Jan 21, 2020 6:37 pm
by Box293
It sounds apache related. Specifically look at the Install Apache Config Files section in this document https://support.nagios.com/kb/article.php?id=96#Ubuntu, most likely re-run the cgi command.

Can you post your apache config please if you are still having issues.

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

Posted: Tue Jan 21, 2020 6:48 pm
by buee
Box293 wrote:It sounds apache related. Specifically look at the Install Apache Config Files section in this document https://support.nagios.com/kb/article.php?id=96#Ubuntu, most likely re-run the cgi command.

Can you post your apache config please if you are still having issues.
Not sure which one you're looking for. This is my default virtualhost configuration (there's another one in the sites-enabled folder for LibreNMS):

Code: Select all

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
If that's not what you're looking for, I can provide the general apache2.conf file; it's much larger so I didn't want to introduce too much noise. Side note, this randomly stopped working. The only possible explanation I can come up with is a routine apt update; apt upgrade pooched it.

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

Posted: Tue Jan 21, 2020 6:58 pm
by Box293
Can you please run the a2enmod commands in this link: https://support.nagios.com/kb/article.php?id=96#Ubuntu

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

Posted: Tue Jan 21, 2020 7:12 pm
by buee
Box293 wrote:Can you please run the a2enmod commands in this link: https://support.nagios.com/kb/article.php?id=96#Ubuntu
For rewrite and cgi, a2enmod came back and said they're already enabled.

Lower in that doc, I noted some more that appeared to be specific to OpenSUSE; version and php7. I don't appear to have the version mod at all and the PHP version currently enabled is 7.3.

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

Posted: Wed Jan 22, 2020 5:18 pm
by Box293
So the doc is created with multiple sections for different OS's to remove confusion.

It might be that the doc is now outdated if Ubuntu has updated PHP to 7 and the doc is built around older PHP versions.