限制Nagios报警次数用escalations
创始人
2024-07-24 06:40:55
0

 

Nagios 

图-Nagios

  Nagios是非常强大的一款监控工具,尤其是它的告警功能,现在网上实现的形式多种多样如结合移动139邮箱、Fetion、MSN等,但是如果服务器出现故障而未能及时的解决,Nagios就会不断的发送告警信息,实在令人头疼。现在用escalations,如下方法可以解决Nagios的告警次数问题。

  系统环境:CentOS 5.2

  Nagios版本:3.0.6

  Nagios安装路径:/usr/local/nagios

  配置文件内容定义:#基本的配置就不再进行注释了。

 

  1.   hosts.cfg  
  2.  
  3.   define host{  
  4.  
  5.   host_name WWW-Server  
  6.  
  7.   alias WWW-Server  
  8.  
  9.   address 193.1.16.100  
  10.  
  11.   check_command check-host-alive  
  12.  
  13.   max_check_attempts 5  
  14.  
  15.   check_period 24x7  
  16.  
  17.   notification_interval 10  
  18.  
  19.   notification_period 24x7  
  20.  
  21.   notification_options d,u,r  
  22.  
  23.   notifications_enabled 1  
  24.  
  25.   contact_groups chengnan  
  26.  
  27.   }  
  28.  

 

 

  1.   Services.cfg  
  2.  
  3.   define service{  
  4.  
  5.   host_name WWW-Server  
  6.  
  7.   service_description Check_HTTP  
  8.  
  9.   check_command check_http  
  10.  
  11.   max_check_attempts 10  
  12.  
  13.   normal_check_interval 3  
  14.  
  15.   retry_check_interval 2  
  16.  
  17.   check_period 24x7  
  18.  
  19.   notification_interval 5  
  20.  
  21.   notification_period 24x7  
  22.  
  23.   notification_options w,u,c,r  
  24.  
  25.   contact_groups admin  
  26.  
  27.   }  
  28.  

 

 

  1.   define service{  
  2.  
  3.   host_name WWW-Server  
  4.  
  5.   service_description Check_Jetty  
  6.  
  7.   check_command check_tcp!8080  
  8.  
  9.   max_check_attempts 10  
  10.  
  11.   normal_check_interval 3  
  12.  
  13.   retry_check_interval 2  
  14.  
  15.   check_period 24x7  
  16.  
  17.   notification_interval 5  
  18.  
  19.   notification_period 24x7  
  20.  
  21.   notification_options w,u,c,r  
  22.  
  23.   contact_groups admin  
  24.  
  25.   }  
  26.  

 

 

  1.   Contacts.cfg  
  2.  
  3.   define contact{  
  4.  
  5.   contact_name chengnan  
  6.  
  7.   alias chengnan  
  8.  
  9.   service_notification_period 24x7  
  10.  
  11.   host_notification_period 24x7  
  12.  
  13.   service_notification_options w,u,c,r  
  14.  
  15.   host_notification_options d,u,r  
  16.  
  17.   service_notification_commands notify-service-by-email  
  18.  
  19.   host_notification_commands notify-host-by-email  
  20.  
  21.   email chengnan@139.com //手机邮箱  
  22.  
  23.   }  
  24.  

 

 

  1.   define contactgroup{  
  2.  
  3.   contactgroup_name chengnan  
  4.  
  5.   alias Nagios Administrators  
  6.  
  7.   members chengnan  
  8.  
  9.   }  
  10.  

#p#
 

 

  除此之外再定义一个联系人

 

  1.   define contact{  
  2.  
  3.   contact_name chengnan_cor  
  4.  
  5.   alias chengnan_cor  
  6.  
  7.   service_notification_period 24x7  
  8.  
  9.   host_notification_period 24x7  
  10.  
  11.   service_notification_options w,u,c,r  
  12.  
  13.   host_notification_options d,u,r  
  14.  
  15.   service_notification_commands notify-service-by-email  
  16.  
  17.   host_notification_commands notify-host-by-email  
  18.  
  19.   email chengnan@company.com //公司邮箱  
  20.  
  21.   }  
  22.  

 

 

  1.   define contactgroup{  
  2.  
  3.   contactgroup_name sysadmin  
  4.  
  5.   alias sysadmin  
  6.  
  7.   members chengnan_cor  
  8.  
  9.   }  
  10.  

#p#
 

 

  然后创建一个配置文件:

  vi escalations.cfg

  escalations有自动调整;不断增加; 逐步上升等意思,本身配置文件的功能是当服务在某一告警次数前没有恢复,告警频率周期将会缩短,同时将告警信息发送至指定联系人。

  其内容为:

  define hostescalation{

  host_name WWW-Server //被监控主机名称,与Hosts.cfg中一致

  first_notification 4 // 第n条信息起,改变频率间隔

  last_notification 0 // 第n条信息起,恢复频率间隔

  notification_interval 30 // 通知间隔(分)

  contact_groups sysadmin

  }

  说明:从第4条告警信息起至服务器恢复前,告警信息发送至sysadmin组下的联系人,告警间隔为30分钟1条信息。

  define serviceescalation{

  host_name WWW-Server //被监控主机名称,与Hosts.cfg中一致

  service_description Check_HTTP,Check_Jetty //被监控服务名称,与Services.cfg中一致

  first_notification 4

  last_notification 0

  notification_interval 30

  contact_groups sysadmin

  }

  保存

  修改nagios.cfg

  vi nagios.cfg

  添加:

  cfg_file=/usr/local/nagios/etc/objects/escalations.cfg

  检查nagios配置文件是否正确

  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

  重新启动nagios服务:

  service nagios restart

  测试:

  服务器启动后停掉被监控测试机的相应服务,确认告警信息是否按照设置发送至不同信箱

#p#

  后记

  escalations这个功能官方给的定义是notification的扩充,使notification变得更加灵活,方便。文中我使用的方法算是耍了个小聪明,将第四条告警信息后的所有信息全部发送至我公司邮箱直至服务器恢复(recovery的信息还是会发送至手机的),从而实现限制告警信息发送至手机的条数。

通过文章的说明解说,我们大致明白了限制Nagios报警次数就用escalations。希望本文对你们有用!

【编辑推荐】

  1. Nagios监控服务器的配置
  2. Nagios监控Windows客户端
  3. Ubuntu下安装运行Nagios
  4. 运维监控Nagios:启动服务
  5. Nagios远程监控软件的装置与设置装备
  6. nagios报警通过飞信
  7. nagios客户端程序的安装

 

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...