用escalations限制Nagios報警次數
整合的飛信之后,如果出現問題未能即使解決的話,那么后果將十分“杯具”,每五分鐘你將收到一條報警短信,你的郵箱也會被報警郵件塞滿。nagios官方也想到了這個問題,于是他們給出了解決辦法,http://nagios.sourceforge.net/docs/3_0/escalations.html,這里是官方的說明,以下是我的做法。
首先編輯contact.cfg,把原有的配置復制一份在下面,變成:
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
email stcomd@163com ;
service_notification_commands notify-service-by-email,service-notify-by-fetion
host_notification_commands notify-host-by-email,host-notify-by-fetion
pager 13691515****
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
define contact{
contact_name scomd
use generic-contact
alias Nagios Admin
email stcomd@163com
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
pager 13691515****
}
define contactgroup{
contactgroup_name sysadmin
alias sysadmin
members scomd
}
然后然后創建一個配置文件: escalations.cfg
#vi /usr/local/nagios/etc/objects/escalations.cfg
添加如下內容:
define serviceescalation{
host_name scomd.com ;被監控主機名稱,多個用逗號隔開
first_notification 4 ; 第4條信息起,改變頻率間隔
last_notification 0 ; 第n條信息起,恢復頻率間隔
notification_interval 30 ; 通知間隔(單位:分)
contact_groups sysadmin
}
define serviceescalation{
host_name scomd.com ;被監控主機名稱
service_description PING ;被監控服務名稱,多個用逗號隔開
first_notification 4
last_notification 0
notification_interval 30
contact_groups sysadmin
}
最后,編輯nagios.cfg文件
#vi /usr/local/nagios/etc/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