Linux Nagios - 错误:无法读取对象配置数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20962668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Nagios - Error: Could not read object configuration data
提问by Riaan Schutte
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...
我们有一个运行在另外两台服务器上的 Nagios 3.2.0 工作版本,但在这些新服务器上,我们使用 apt-get install 安装了它,但不断遇到以下问题。权限和配置文件都是安装时的默认设置,将它与我们拥有的 Nagios 的工作版本进行比较时,一切似乎都是正确的...
Note: The Nagios website is running but when i click on any option on the left i get this...
注意:Nagios 网站正在运行,但是当我单击左侧的任何选项时,我得到了这个...
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:
/var/log/nagios3/nagios.log 没有给出错误,只是一堆:
...
[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:
不是权限问题,也不是尝试将所有内容更改为 nagios 用户和组,但没有运气:
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.
把它改回root。
Stopped Nagios and restarted but still nothing. Please help!
停止 Nagios 并重新启动,但仍然没有。请帮忙!
采纳答案by Riaan Schutte
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.
前几天解决了。这些服务器上的 Apache 很久以前就被配置为以不同的用户身份运行,而不是 www-data。这并没有解决我们当时遇到的问题,所以我们保持原样,忘记了 apache。现在我们在 apache 上运行了 Nagios,这导致了问题。所以这最终是一个许可问题。
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
注意:在检查是否是权限问题时,不要只检查文件和目录权限,还要检查需要访问它们的内容是否确实在其配置中以该用户身份运行。在这种情况下,它被更改为/etc/apache2/envvars
Lesson learnt.
学习到教训了。
回答by Tharanga Abeyseela
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.
这是一个权限问题,网络服务器用户应该能够访问 nagios 目录结构。尝试以下。假设您的 Web 服务器没有以 root 用户身份运行。
chgrp -R webserver_user /var/cache/nagiosx/
and also check other nagios directories for correct permissions.
并检查其他 nagios 目录以获得正确的权限。
回答by Guntram Blohm supports Monica
The nagios configuration file is referenced in the cgi config file, /etc/nagios3/cgi.cfg
. Check if that file contains the line
nagios 配置文件在 cgi 配置文件中引用,/etc/nagios3/cgi.cfg
. 检查该文件是否包含该行
main_config_file=/etc/nagios3/nagios.cfg
回答by myersguo
run nagios as daemon
将 nagios 作为守护进程运行
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
回答by amoe
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
.
就我而言,它是对 /var/cache/nagios3 的权限。您可以通过跟踪 CGI 来确认,即sudo su -s /bin/sh -c 'REQUEST_METHOD=GET strace -fo /tmp/strace.log /usr/lib/cgi-bin/nagios3/status.cgi' www-data
.
回答by Mark Horgan
In my case the web server didn't have permission to access /var/log/nagios/nagios.log
.
在我的情况下,Web 服务器无权访问/var/log/nagios/nagios.log
.
回答by hlovdal
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:
就我而言(Nagios 4、Centos 7),由于 selinux 权限(尽管没有任何拒绝的痕迹记录到 syslog),我收到了这个错误。测试问题是否是 selinux 的简单方法:
- Load page, confirm failue.
- Run command
getenforce
, should return Enforcing. - Run command
setenforce 0
. - Reload page. If it now works, the error is related to selinux permissions.
- 加载页面,确认失败。
- 运行 command
getenforce
,应该返回 Enforcing。 - 运行命令
setenforce 0
。 - 重新加载页面。如果它现在有效,则错误与 selinux 权限有关。
Optional:
可选的:
- Run command
setenforce 1
. - Reload page, it should fail again.
- 运行命令
setenforce 1
。 - 重新加载页面,它应该再次失败。
回答by rbrooker
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.
有一个 SELinux 问题,如果您不想关闭安全性,您可以为这种情况创建一个规则。
to see the error in human readable format
以人类可读的格式查看错误
audit2allow -a -w
have audit2allow create a te allow rule
让 audit2allow 创建一个允许规则
audit2allow -a -M nagios-www
semange nagios-www.pp
refresh and see it works
刷新并查看它的工作原理
回答by Ale
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
使用 EPEL 的 RPM 包从 Nagios 3.5 更新到 Nagios 4.3 后遇到了同样的问题。解决了安装包含 SELinux 配置文件 ( yum install nagios-selinux
)的相应包的问题。更多详情:https: //serverfault.com/q/894349/217522
回答by Rodrigo Caballero
In my case I had to bring broader permissions to objects.cachefile. In my case my file is at: /usr/local/nagios/var/objects.cache
就我而言,我必须为objects.cache文件带来更广泛的权限。就我而言,我的文件位于:/usr/local/nagios/var/objects.cache
hope this helps
希望这可以帮助