限制Nagios报警次数用escalations

运维 系统运维
Nagios是一个可运行在Linux/Unix平台之上的监视系统,Nagios是比较火的!但是他的报警系统太烦,次数太多,让我们在文章中找找答案解决掉他!

 

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客户端程序的安装

 

责任编辑:赵鹏 来源: 网络转载
相关推荐

2011-03-24 08:56:23

escalationsNagios报警

2011-03-21 15:44:52

escalationsNagios

2011-03-23 13:32:14

Nagios飞信

2011-03-25 13:10:08

2011-03-24 08:56:21

Nagios邮件

2011-03-23 09:07:49

Nagios飞信

2011-03-22 16:31:27

Nagios

2011-03-23 12:55:51

NagiosMSN飞信

2011-03-23 09:07:50

Nagios短信

2011-03-24 13:00:31

Nagios飞信

2011-03-24 10:08:42

Nagios飞信Linux

2011-04-06 14:24:18

2018-12-04 09:02:14

正则表达式回溯WEB安全

2011-03-22 15:17:14

Nagios安装

2011-03-22 15:17:14

Nagios安装

2011-03-22 15:17:13

Nagios监控

2015-01-05 09:59:42

2011-03-17 15:02:48

2011-03-21 15:35:01

Nagiosnagios-plug安装

2011-03-31 16:05:18

Redhat配置nagios
点赞
收藏

51CTO技术栈公众号