最近在安装nagios,出现几个错误记录:

一 检查nagios配置的时候出现错误如下:

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

检查的命令如下:

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

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



整体报错如下:

  1. [root@kelly ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  2.  
  3. Nagios Core 3.4.3
  4. Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
  5. Copyright (c) 1999-2009 Ethan Galstad
  6. Last Modified: 11-30-2012
  7. License: GPL
  8.  
  9. Website: http://www.nagios.org
  10. Reading configuration data...
  11. Read main config file okay...
  12. Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
  13. Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
  14. Processing object config file '/usr/local/nagios/etc/objects/hosts.cfg'...
  15. Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
  16. Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
  17. Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
  18. Warning: Duplicate definition found for host 'kelly' (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 25)
  19. Error: Could not add object property in file '/usr/local/nagios/etc/objects/localhost.cfg' on line 29.
  20. Error processing object config files!
  21.  
  22. ***> One or more problems was encountered while processing the config files...
  23.  
  24. Check your configuration file(s) to ensure that they contain valid
  25. directives and data defintions. If you are upgrading from a previous
  26. version of Nagios, you should be aware that some variables/definitions
  27. may have been removed or modified in this version. Make sure to read
  28. the HTML documentation regarding the config files, as well as the
  29. 'Whats New' section to find out what has changed.

解决方案如下:

删除hosts.cfg文件,在nagios.cfg文件中不加入hosts.cfg文件的加载,从而可以解决问题。

原因:

主要原因是在hosts.cfg文件中定义了主机的信息,而在localhost.cfg文件中又再次定义了主机的信息,从而导致了定义的信息产生了重复。

在配置文件nagios.cfg中可以看到已经定义了主机信息:

  1. define host{
  2. 26 use linux-server ; Name of host template to use
  3. 27 ; This host definition will inherit all variables that are defined
  4. 28 ; in (or inherited by) the linux-server host templ ate definition.
  5. 29 host_name kelly
  6. 30 alias kelly
  7. 31 address 192.168.1.104
  8. 32 }

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

二 在web页面无法查看相关的信息,日志中报错Error: Could not create external command file '/usr/local/nagios/var/rw/nagios.cmd' as named pipe: (13) -> Permission denied

具体的报错信息在日志中可以看到,报错信息如下:

.

  1. [1427280603] Nagios 3.4.3 starting... (PID=19238)
  2. [1427280603] Local time is Wed Mar 25 18:50:03 CST 2015
  3. [1427280603] LOG VERSION: 2.0
  4. [1427280603] Finished daemonizing... (New PID=19239)
  5. [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.
  6. [1427280603] Bailing out due to errors encountered while trying to initialize the external command file... (PID=19239)

日志路径如下:

  1. [root@kelly var]# pwd
  2. /usr/local/nagios/var
  3. [root@kelly var]# ls -l
  4. total 72
  5. drwxrwxr-x 2 nagios nagios 4096 Mar 25 17:47 archives
  6. -rw-r--r-- 1 nagios nagios 6 Mar 25 18:52 nagios.lock
  7. -rw-r--r-- 1 nagios nagios 4300 Mar 25 19:52 nagios.log
  8. -rw-r--r-- 1 nagios nagios 13695 Mar 25 18:52 objects.cache
  9. -rw------- 1 nagios nagios 14703 Mar 25 19:52 retention.dat
  10. drwxrwxr-x 2 nagios nagios 4096 Mar 25 18:52 rw
  11. drwxr-xr-x 3 root root 4096 Mar 25 17:47 spool
  12. -rw-rw-r-- 1 nagios nagios 15286 Mar 25 20:21 status.dat

解决方案:

查看目录是否存在,不存在就建立目录,然后修改用户,然后修改权限即可:

  1. [root@kelly var]# chown nagios:nagios rw
  1. [root@kelly var]# chmod g+rwx rw

然后重启nagios即可。

  1. [root@kelly var]# service nagios restart

可以看到重启之后成功的日志:

  1. [1427280727] Nagios 3.4.3 starting... (PID=19298)
  2. [1427280727] Local time is Wed Mar 25 18:52:07 CST 2015
  3. [1427280727] LOG VERSION: 2.0
  4. [1427280727] Finished daemonizing... (New PID=19299)
  5. [1427284327] Auto-save of retention data completed successfully.

原因:主要是因为权限的问题,在读取文件的时候,设定的用户和组都在配置文件中,如下:

  1. [root@kelly etc]# ls -l nagios.cfg
  2. -rw-r--r-- 1 root root 44777 Mar 25 18:50 nagios.cfg
  1. nagios_user=nagios
  2. 125
  3. 126
  4. 127
  5. 128 # NAGIOS GROUP
  6. 129 # This determines the effective group that Nagios should run as.
  7. 130 # You can either supply a group name or a GID.
  8. 131
  9. 132 nagios_group=nagios

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

安装nagios出现的两个错误记录的更多相关文章

  1. Redhat6.8安装Oracle11g下遇到两个问题记录

    问题一: 刚刚安装完毕Oracle之后,尝试sqlplus登陆报错,TNS:net service name is incorrectly specified 参考文章:关于环境变量ORACLE_SI ...

  2. windows环境下基于pycharm安装Redis出现的两个错误解决方案

    说明:下面给出的两个链接是解决安装和使用Redis的时候遇到的两个问题参考的博客网址,本文有解释不清楚的地方可以原博客查看,侵权删! Q1参考链接-https://blog.csdn.net/maqu ...

  3. 记录Linux下安装elasticSearch时遇到的一些错误

    记录Linux下安装elasticSearch时遇到的一些错误 http://blog.sina.com.cn/s/blog_c90ce4e001032f7w.html (2016-11-02 22: ...

  4. 安装nagios出现的错误

    最近安装nagios时,检查的的状态都没有什么问题,就是监控系统的状态显示不出来 检测的结果如下: [root@lb02 ~]# /etc/init.d/httpd start Starting ht ...

  5. 6.5安装nagios

    最近因为,科研需要,接触上了Nagios,这里,我将安装笔记做个详解.为自己后续需要和博友们学习! VMware workstation 11 的下载 VMWare Workstation 11的安装 ...

  6. Centos 6.x 安装Nagios及WEB管理nagiosql实现windows及linux监控指南

    一.Nagios简介 Nagios是一款开源的电脑系统和网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设置,打印机等.在系统或服务状态异常时发出邮件或短信报 ...

  7. hadoop错误记录部分总结

    错误记录与分析 错误1:java.net.BindException: Port in use: localhost:0 datanode节点启动时报错 日志信息如下: Exiting with st ...

  8. uploadify插件Http Error(302)错误记录(MVC)

    由于项目(asp.net MVC)需要做一个附件上传的功能,使用的是jQuery的Uploadify插件的2.1.0版本,上传文件到自己项目指定的文件夹下面.做完之后,在谷歌上测试是正确的,在火狐上报 ...

  9. CentOS 安装nagios

    Nagios的介绍: 1.Nagios是一个监控系统运行状态和网络信息的监控系统.它能监控所指定的本地或远程主机的系统状态以及运行的服务,同时提供异常通知的功能. 2. Nagios可运行在Linux ...

随机推荐

  1. lintcode:数字三角形

    题目: 数字三角形 给定一个数字三角形,找到从顶部到底部的最小路径和.每一步可以移动到下面一行的相邻数字上. 样例 比如,给出下列数字三角形: [      [2],     [3,4],    [6 ...

  2. CentOS7安装Hadoop2.7完整流程

    总体思路,准备主从服务器,配置主服务器可以无密码SSH登录从服务器,解压安装JDK,解压安装Hadoop,配置hdfs.mapreduce等主从关系. 1.环境,3台CentOS7,64位,Hadoo ...

  3. 一步一步开发sniffer(Winpcap+MFC)(一)工欲善其事,必先配环境——配置winpcap开发环境(图文并茂,非常清楚)

    http://blog.csdn.net/litingli/article/details/5950962

  4. 不重启使XP环境变量生效

    不重启使XP环境变量生效 http://www.pkghost.cn/wz/sort0185/8874.html 在“我的电脑”->“属性”->“高级”->“环境变量”中增加或修改环 ...

  5. jQuery好用插件

    jQuery图片轮播插件(smallslider):http://fz.sjtu.edu.cn/zsw/js/smallslider/ jQuery消息通知(noty):http://www.360d ...

  6. sql 随笔 2015-07-02

    sql 自定义函数 --检查函数是否存在 if exists (select * from dbo.sysobjects where id = object_id(N'dbo.pTitleCase') ...

  7. HDU 3308 线段树 最长连续上升子序列 单点更新 区间查询

    题意: T个测试数据 n个数 q个查询 n个数 ( 下标从0开始) Q u v 查询 [u, v ] 区间最长连续上升子序列 U u v 把u位置改成v #include<iostream> ...

  8. hibernate--query接口初步

    Query session.createQuery(String hql)方法; * hibernate的session.createQuery()方法是使用HQL(hibernate的查询语句)语句 ...

  9. php整理(一):变量和字符串

    PHP中的变量: 1. 定义:$符号来定义变量 2. 说明: (1)PHP弱语言,定义变量的时候不用声明类型,但是并不代表PHP没有数据类型 (2)变量名是区分大小写的,只能是数字,字母或者下划线 ( ...

  10. NuGet在2015中的使用

    NuGet Package Restore  https://docs.nuget.org/Consume/Package-Restore 以https://github.com/andburn/hd ...