设为首页 收藏本站
查看: 1458|回复: 0

安装nagios出现的两个错误记录

[复制链接]

尚未签到

发表于 2015-11-23 07:29:03 | 显示全部楼层 |阅读模式
  最近在安装nagios,出现几个错误记录:
  一 检查nagios配置的时候出现错误如下:
  

Warning: Duplicate definition found for host 'kelly' (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 25)                                                                                       
Error: Could not add object property in file '/usr/local/nagios/etc/objects/localhost.cfg' on line 29.        
Error processing object config files!

检查的命令如下:
  
  

[iyunv@kelly ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

在进行各种检查修改,发现也没找到原因,从而每修改一次就进行检查一次,从而来判断是哪里的问题,最后发现是定义了两个文件,一个是hosts.cfg文件,一个是localhost.cfg文件,只要在nagios.cfg中加入此配置就会进行报错。



整体报错如下:  
  

[iyunv@kelly ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 3.4.3
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad                                          
Last Modified: 11-30-2012                                                      
License: GPL                                                                  
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/hosts.cfg'...   
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...  
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...  
Warning: Duplicate definition found for host 'kelly' (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 25)                                                                                       
Error: Could not add object property in file '/usr/local/nagios/etc/objects/localhost.cfg' on line 29.        
Error processing object config files!                                                                     

***> One or more problems was encountered while processing the config files...
Check your configuration file(s) to ensure that they contain valid
directives and data defintions.  If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version.  Make sure to read
the HTML documentation regarding the config files, as well as the     
'Whats New' section to find out what has changed.                     


解决方案如下:  
  删除hosts.cfg文件,在nagios.cfg文件中不加入hosts.cfg文件的加载,从而可以解决问题。
  原因:
  主要原因是在hosts.cfg文件中定义了主机的信息,而在localhost.cfg文件中又再次定义了主机的信息,从而导致了定义的信息产生了重复。
  在配置文件nagios.cfg中可以看到已经定义了主机信息:
  define host{
26         use                     linux-server            ; Name of host template to use
27                                                         ; This host definition will inherit all variables     that are defined
28                                                         ; in (or inherited by) the linux-server host templ    ate definition.
29         host_name               kelly
30         alias                   kelly
31         address                 192.168.1.104
32         }


而在hosts.cfg文件中再次定义就会造成定义信息重复,从而导致上面的问题。
  


  二 在web页面无法查看相关的信息,日志中报错Error: Could not create external command file '/usr/local/nagios/var/rw/nagios.cmd' as named pipe: (13) -> Permission denied
  具体的报错信息在日志中可以看到,报错信息如下:
  .[1427280603] Nagios 3.4.3 starting... (PID=19238)
[1427280603] Local time is Wed Mar 25 18:50:03 CST 2015
[1427280603] LOG VERSION: 2.0                          
[1427280603] Finished daemonizing... (New PID=19239)   
[1427280603] Error: Could not create external command file '/usr/local/nagios/var/rw/nagios.cmd' as named pipe: (13) -> Permission denied.  If this file already exists and you are sure that another copy of Nagios is not running, you should delete this file.                                                                        
[1427280603] Bailing out due to errors encountered while trying to initialize the external command file... (PID=19239)

日志路径如下:
  [iyunv@kelly var]# pwd
/usr/local/nagios/var
[iyunv@kelly var]# ls -l
total 72
drwxrwxr-x 2 nagios nagios  4096 Mar 25 17:47 archives
-rw-r--r-- 1 nagios nagios     6 Mar 25 18:52 nagios.lock
-rw-r--r-- 1 nagios nagios  4300 Mar 25 19:52 nagios.log
-rw-r--r-- 1 nagios nagios 13695 Mar 25 18:52 objects.cache
-rw------- 1 nagios nagios 14703 Mar 25 19:52 retention.dat
drwxrwxr-x 2 nagios nagios  4096 Mar 25 18:52 rw
drwxr-xr-x 3 root   root    4096 Mar 25 17:47 spool
-rw-rw-r-- 1 nagios nagios 15286 Mar 25 20:21 status.dat


解决方案:
  查看目录是否存在,不存在就建立目录,然后修改用户,然后修改权限即可:
  [iyunv@kelly var]# chown nagios:nagios rw

[iyunv@kelly var]# chmod g+rwx rw  

然后重启nagios即可。
  [iyunv@kelly var]# service nagios restart


可以看到重启之后成功的日志:
  [1427280727] Nagios 3.4.3 starting... (PID=19298)
[1427280727] Local time is Wed Mar 25 18:52:07 CST 2015
[1427280727] LOG VERSION: 2.0
[1427280727] Finished daemonizing... (New PID=19299)
[1427284327] Auto-save of retention data completed successfully.

原因:主要是因为权限的问题,在读取文件的时候,设定的用户和组都在配置文件中,如下:
  [iyunv@kelly etc]# ls -l nagios.cfg
-rw-r--r-- 1 root root 44777 Mar 25 18:50 nagios.cfg


nagios_user=nagios
125
126
127
128 # NAGIOS GROUP
129 # This determines the effective group that Nagios should run as.
130 # You can either supply a group name or a GID.
131
132 nagios_group=nagios



  权限设定好之后,在页面就能正确看到相关信息。


  


  




  


  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-142330-1-1.html 上篇帖子: nagios 监控内存-增加新插件方法 下篇帖子: nagios安装和配置笔记
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表