34tg 发表于 2015-8-17 09:48:01

Nagios配置之Windows

1.1   windows客户端安装    NSClient++
                注意:安装后中会有提示允许那些主机listen,添加nagios-server主机。安装完后会提供一个密码,记得保存,server端会用到。
   1.2    启用nagios.cfg中的 cfg_file=/usr/local/nagios/etc/objects/windows.cfg,如果需要监控多台Windows主机,建议启用cfg_dir==/usr/local/nagios/etc/windows
    1.3    配置templates.cfg,添加如下内容
#windows host
define host{
      name                      Windows         ; 模板主机名(可以自己定义),供后面windows.cfg调用
      use                         generic-host    ; Inherit default values from the generic-host template
      check_period          24x7                ; 检查周期,也可以设置成其它的,例如workhours,具体的可以在/usr/local/nagios/etc/object/timeperiod里面定义
      check_interval             5               ; Actively check the server every 5 minutes
      retry_interval               1               ; Schedule host check retries at 1 minute intervals
      max_check_attempts   10               ; Check each server 10 times (max)
      check_command          check-host-alive      ; Default command to check if servers are "alive"
      notification_period      24x7            ; 发送告警时间段,就是什么时间可以发送告警给管理员,与check_period一样自定
      notification_interval   30               ; 告警发送周期,这里默认是分钟单位,30的意思是每30分钟发送一次告警
      notification_options   d,r            ; 需要发送告警的级别,就是当发生什么事件时告警,d表示down,r表示recovery
      contact_groups          admins          ; 联系用户组,就是将告警发送给哪个管理员组
      hostgroups                windows      ; 主机组名(可以自己定义):
      register                           0                           ; DONT REGISTER THIS - ITS JUST A TEMPLATE
      }

#windows service   
define service{
      name                            windows-service         ; 模板服务名称
      active_checks_enabled         1                     ; 启用检查,1表示启用,0表示不启用
      passive_checks_enabled          1                     ; Passive service checks are enabled/accepted
      parallelize_check               1                     ; Active service checks should be parallelized (disabling this can lead to major performance problems)
      obsess_over_service             1                     ;关注该服务
      check_freshness               0                     ; Default is to NOT check service 'freshness'
      notifications_enabled         1                     ; 允许提醒
      event_handler_enabled         1                     ; 启用事件处理程序
      flap_detection_enabled          1                     ; Flap detection is enabled
      process_perf_data               1                        ; 性能数据
      retain_status_information       1                      ; 保留状态信息
      retain_nonstatus_information    1                   ; 保留非状态信息
      is_volatile                  0                                  ; 服务是否稳定,1表示稳定,0表示不稳定
      check_period                  workhours            ; 检查周期
      max_check_attempts            3                     ; 重新检查该服务3次,以确定其最终状态
      normal_check_interval         10                      ; 在正常情况下,每10分钟检查一个服务
      retry_check_interval            2                           ; 每2分钟重新检查一次,直到一个异常的状态可以被确定
      contact_groups                  admins                  ; 联系组
      notification_options            w,u,c,r                  ; 告警级别warning, unknown, critical,recovery
      notification_interval         60                        ; 发送告警的周期
      notification_period             workhours            ; 发送告警的时间段
         register                        0                           
}

      1.4 配置windows.cfg
define host{
      use                     Windows       ; 这里调用的templates.cfg中配置的主机模板
      host_name      PC-1               ; 主机名
      alias                  Test 1            ; 主机别名
      address             192.168.1.3    ; 主机IP
      }
define hostgroup{
      hostgroup_namewindows             ; 主机所属组
      alias                   Windows Cline       ; 组别名
      members            PC-1                     ;组成员
      }

define service{
      use                              windows-service                  ;调用templates中service的模板
      host_name                     PC-1                                     ;应用于哪台主机,如果有多台,用逗号隔开
      service_description      NSClient++ Version             ;服务描素,这里的会显示在网页中
      check_command         check_nt!CLIENTVERSION -s password    ;password就是SClient++的密码
      }
define service{
      use                                 windows-service
      host_name                     PC-1
      service_description      C:\ Drive Space
      check_command         check_nt!USEDDISKSPACE!-l c -w 90 -c 99 -s password    ;-l后面跟随的是磁盘符
}

页: [1]
查看完整版本: Nagios配置之Windows