免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7447 | 回复: 8
打印 上一主题 下一主题

[其他] 谈论一个关于nagios的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-11-01 11:29 |只看该作者 |倒序浏览
本帖最后由 305838894 于 2012-11-01 11:45 编辑

我话了几天的时间把整体框架配置好了,但是在配具体的检测的时间出问题,一直提示我说我的command有问题,可是我就没有修改这个东西啊,我把我的思路说一下
我是用了了这个自带的templates里面的模板,用了里面generic-contact,generic-host,linux-server,generic-service,local-service。
我的contacts.cfg里面是这样写的
  1.     define contact{
  2.             contact_name                    nagios  ; Short name of user
  3.             use                             generic-contact         ; 引用了模板里面的generic-contact
  4.             alias                           Nagios          ; Full name of user

  5.             email                           305838894@qq.com      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
  6.             }
复制代码
hosts.cfg是这样写的
  1.     define host{
  2.        use           linux-server
  3.        host_name     test
  4.        alias         gaofeng-test
  5.        address       192.168.39.73
  6.     }
复制代码
service是这样写的
  1.     define service{
  2.        use                   local-service
  3.        host_name             test
  4.        service_description   ping
  5.        check_command         check_ping!100.0,20%!500.0,60%
  6.     }
复制代码
其他的都没修改,然后我验证就一直提示

Nagios Core 3.4.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 05-11-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/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Warning: Duplicate definition found for command 'check-host-alive' (config file '/usr/local/nagios/etc/objects/commands.cfg', starting on line 56)
Error: Could not add object property in file '/usr/local/nagios/etc/objects/commands.cfg' on line 57.
   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.

我在补充下引用到几个模块的代码
  1. define contact{
  2.         name                            generic-contact         ; The name of this contact template
  3.         service_notification_period     24x7                    ; service notifications can be sent anytime
  4.         host_notification_period        24x7                    ; host notifications can be sent anytime
  5.         service_notification_options    w,u,c,r,f,s             ; send notifications for all service states, flapping events, and scheduled downtime events
  6.         host_notification_options       d,u,r,f,s               ; send notifications for all host states, flapping events, and scheduled downtime events
  7.         service_notification_commands   notify-service-by-email ; send service notifications via email
  8.         host_notification_commands      notify-host-by-email    ; send host notifications via email
  9.         register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
  10.         }
复制代码

  1. define host{
  2.         name                            generic-host    ; The name of this host template
  3.         notifications_enabled           1               ; Host notifications are enabled
  4.         event_handler_enabled           1               ; Host event handler is enabled
  5.         flap_detection_enabled          1               ; Flap detection is enabled
  6.         failure_prediction_enabled      1               ; Failure prediction is enabled
  7.         process_perf_data               1               ; Process performance data
  8.         retain_status_information       1               ; Retain status information across program restarts
  9.         retain_nonstatus_information    1               ; Retain non-status information across program restarts
  10.         notification_period             24x7            ; Send host notifications at any time
  11.         register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
  12.         }


  13. # Linux host definition template - This is NOT a real host, just a template!

  14. define host{
  15.         name                            linux-server    ; The name of this host template
  16.         use                             generic-host    ; This template inherits other values from the generic-host template
  17.         check_period                    24x7            ; By default, Linux hosts are checked round the clock
  18.         check_interval                  5               ; Actively check the host every 5 minutes
  19.         retry_interval                  1               ; Schedule host check retries at 1 minute intervals
  20.         max_check_attempts              10              ; Check each Linux host 10 times (max)
  21.         check_command                   check-host-alive ; Default command to check Linux hosts
  22.         notification_period             workhours       ; Linux admins hate to be woken up, so we only notify during the day
  23.                                                         ; Note that the notification_period variable is being overridden from
  24.                                                         ; the value that is inherited from the generic-host template!
  25.         notification_interval           120             ; Resend notifications every 2 hours
  26.         notification_options            d,u,r           ; Only send notifications for specific host states
  27.         contact_groups                  admins          ; Notifications get sent to the admins by default
  28.         register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
  29.         }
复制代码
  1. define service{
  2.         name                            generic-service         ; The 'name' of this service template
  3.         active_checks_enabled           1                       ; Active service checks are enabled
  4.         passive_checks_enabled          1                       ; Passive service checks are enabled/accepted
  5.         parallelize_check               1                       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
  6.         obsess_over_service             1                       ; We should obsess over this service (if necessary)
  7.         check_freshness                 0                       ; Default is to NOT check service 'freshness'
  8.         notifications_enabled           1                       ; Service notifications are enabled
  9.         event_handler_enabled           1                       ; Service event handler is enabled
  10.         flap_detection_enabled          1                       ; Flap detection is enabled
  11.         failure_prediction_enabled      1                       ; Failure prediction is enabled
  12.         process_perf_data               1                       ; Process performance data
  13.         retain_status_information       1                       ; Retain status information across program restarts
  14.         retain_nonstatus_information    1                       ; Retain non-status information across program restarts
  15.         is_volatile                     0                       ; The service is not volatile
  16.         check_period                    24x7                    ; The service can be checked at any time of the day
  17.         max_check_attempts              3                       ; Re-check the service up to 3 times in order to determine its final (hard) state
  18.         normal_check_interval           10                      ; Check the service every 10 minutes under normal conditions
  19.         retry_check_interval            2                       ; Re-check the service every two minutes until a hard state can be determined
  20.         contact_groups                  admins                  ; Notifications get sent out to everyone in the 'admins' group
  21.         notification_options            w,u,c,r                 ; Send notifications about warning, unknown, critical, and recovery events
  22.         notification_interval           60                      ; Re-notify about service problems every hour
  23.         notification_period             24x7                    ; Notifications can be sent out at any time
  24.          register                        0                      ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
  25.         }


  26. # Local service definition template - This is NOT a real service, just a template!

  27. define service{
  28.         name                            local-service           ; The name of this service template
  29.         use                             generic-service         ; Inherit default values from the generic-service definition
  30.         max_check_attempts              4                       ; Re-check the service up to 4 times in order to determine its final (hard) state
  31.         normal_check_interval           5                       ; Check the service every 5 minutes under normal conditions
  32.         retry_check_interval            1                       ; Re-check the service every minute until a hard state can be determined
  33.         register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
  34.         }
复制代码

论坛徽章:
0
2 [报告]
发表于 2012-11-01 11:35 |只看该作者
Error: Could not add object property in file '/usr/local/nagios/etc/objects/commands.cfg' on line 57.

把commands.cfg的第56行后面的一段贴出来看下

论坛徽章:
0
3 [报告]
发表于 2012-11-01 11:42 |只看该作者
  1. ################################################################################


  2. # This command checks to see if a host is "alive" by pinging it
  3. # The check must result in a 100% packet loss or 5 second (5000ms) round trip
  4. # average time to produce a critical error.
  5. # Note: Five ICMP echo packets are sent (determined by the '-p 5' argument)

  6. # 'check-host-alive' command definition
  7. define command{
  8.         command_name    check-host-alive
  9.         command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
  10.         }




  11. ################################################################################
复制代码
这行是56开始define command{

回复 2# deweiku


   

论坛徽章:
0
4 [报告]
发表于 2012-11-01 11:56 |只看该作者
define host{
       use           linux-server
       host_name     test
       alias         gaofeng-test
       address       192.168.39.73
       check_command           check-host-alive
    }

host.cfg下面加一行 check_command           check-host-alive 试试

论坛徽章:
0
5 [报告]
发表于 2012-11-01 14:48 |只看该作者
我的host文件use了linux-server,而linux-server是我引用模板的,模板里面是有对host定义的代码如下
  1. define host{
  2.         name                            linux-server    ; The name of this host template
  3.         use                             generic-host    ; This template inherits other values from the generic-host template
  4.         check_period                    24x7            ; By default, Linux hosts are checked round the clock
  5.         check_interval                  5               ; Actively check the host every 5 minutes
  6.         retry_interval                  1               ; Schedule host check retries at 1 minute intervals
  7.         max_check_attempts              10              ; Check each Linux host 10 times (max)
  8.         check_command                   check-host-alive ; Default command to check Linux hosts
  9.         notification_period             workhours       ; Linux admins hate to be woken up, so we only notify during the day
  10.                                                         ; Note that the notification_period variable is being overridden from
  11.                                                         ; the value that is inherited from the generic-host template!
  12.         notification_interval           120             ; Resend notifications every 2 hours
  13.         notification_options            d,u,r           ; Only send notifications for specific host states
  14.         contact_groups                  admins          ; Notifications get sent to the admins by default
  15.         register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
  16.         }
复制代码
回复 4# deweiku


   

论坛徽章:
0
6 [报告]
发表于 2012-11-01 16:56 |只看该作者
你仔细检查一下,就是那几个配置文件的问题,nagios很严格 一个空格都不行

论坛徽章:
0
7 [报告]
发表于 2012-11-02 10:41 |只看该作者
你看看你的commands.cfg里是不是定义了两个check-host-alive。

论坛徽章:
0
8 [报告]
发表于 2012-11-03 11:10 |只看该作者
找到原因了 谢谢你的回答啊回复 6# deweiku


   

论坛徽章:
0
9 [报告]
发表于 2017-03-21 16:54 |只看该作者
楼主不把原因说出来,来厚道啊!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP