Question

We have a working version of Nagios 3.2.0 running on two other servers but on these new server we installed it using apt-get install but keep getting the following problem. The permissions and config file is all default from install and everything seems correct when comparing it to the working versions we have of Nagios...

Note: The Nagios website is running but when i click on any option on the left i get this...

Error: Could not read object configuration data!  
Verify configuration options using the -v command-line option to check for errors. 
Check the Nagios log file for messages relating to startup or status data errors.

Running

sudo /usr/sbin/nagios3 -v /etc/nagios3/nagios.cfg

Gives:

...
Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

/var/log/nagios3/nagios.log gives no errors, just a bunch of:

...
[1389054450] Auto-save of retention data completed successfully.
[1389058050] Auto-save of retention data completed successfully.

Not a permission issue either tried changing everything to nagios user and group but no luck:

drwxr-xr-x   4 root root    4096 2013-12-10 16:35 .
drwxr-xr-x 141 root root   12288 2014-01-06 16:27 ..
-rw-r--r--   1 root root    1905 2011-06-08 01:07 apache2.conf
-rw-r--r--   1 root root   12218 2011-06-08 01:08 cgi.cfg
-rw-r--r--   1 root root    2441 2011-06-08 01:08 commands.cfg
drwxr-xr-x   2 root root    4096 2013-12-10 16:35 conf.d
-rw-r--r--   1 root root      26 2013-12-10 16:35 htpasswd.users
-rw-r--r--   1 root root   43769 2011-06-08 01:08 nagios.cfg
-rw-r-----   1 root nagios  1293 2011-06-08 01:07 resource.cfg
drwxr-xr-x   2 root root    4096 2013-12-10 16:35 stylesheets

Changed it back to root.

Stopped Nagios and restarted but still nothing. Please help!

Was it helpful?

Solution 3

Solved it a few days ago. Apache on these servers had been configured long ago to run as a different user, not www-data. This did not solve the problem we had back then so we left it as is and forgot about apache. Now that we have Nagios running on apache this caused the problem. So it was a permission issue in the end.

Note: When checking if it is a permission issue, don't just check the file and directory permissions, check that what needs access to them is indeed running as that user in its configuration. In this case it was changed in /etc/apache2/envvars

Lesson learnt.

OTHER TIPS

This is a permission issue, webserver user should be able to accees nagios directory structure. try the following . assuming your web server is not running as the root user.

chgrp -R webserver_user /var/cache/nagiosx/  

and also check other nagios directories for correct permissions.

run nagios as daemon

/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg  

In my case (Nagios 4, Centos 7), I got this error because of selinux permissions (although no traces of any denies were logged to syslog). Simple way to test if the issue is selinux:

  1. Load page, confirm failue.
  2. Run command getenforce, should return Enforcing.
  3. Run command setenforce 0.
  4. Reload page. If it now works, the error is related to selinux permissions.

Optional:

  1. Run command setenforce 1.
  2. Reload page, it should fail again.

There was a SELinux issue, and if you don't like to turn off the security, you can create a rule just for this situation.

to see the error in human readable format

audit2allow -a -w 

have audit2allow create a te allow rule

audit2allow -a -M nagios-www
semange nagios-www.pp

refresh and see it works

The nagios configuration file is referenced in the cgi config file, /etc/nagios3/cgi.cfg. Check if that file contains the line

main_config_file=/etc/nagios3/nagios.cfg

In my case it was permissions on /var/cache/nagios3. You can confirm it by straceing the CGI, i.e. sudo su -s /bin/sh -c 'REQUEST_METHOD=GET strace -fo /tmp/strace.log /usr/lib/cgi-bin/nagios3/status.cgi' www-data.

In my case the web server didn't have permission to access /var/log/nagios/nagios.log.

Had the same problem after an update from Nagios 3.5 to Nagios 4.3 using the RPM packages from EPEL. Solved installing the appropriate package containing the SELinux profile (yum install nagios-selinux). For more details: https://serverfault.com/q/894349/217522

In my case I had to bring broader permissions to objects.cache file. In my case my file is at: /usr/local/nagios/var/objects.cache

hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top