解決nagios報警不發郵件通知一例 技術
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
http://skymax.blog.51cto.com/365901/131770
http://bbs.chinaunix.net/viewthread.php?tid=1416669
http://net.zdnet.com.cn/network_security_zone/2008/0922/1141888.shtml
http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html
今天早上來到公司,開啟nagios頁面,發現服務這部分有10多個嚴重的報警,都是紅色的,蚊子我就特別的詫異了,週六的時候我還收到了很多的warning的郵件呢,怎麼這兩天這麼消停呢,好在目前還只是在測試階段,不然,可就鬱悶壞了。
不說這個了,先來排查錯誤吧。
第一個想到的是warning報警發了郵件,而CRITICAL就報警不發郵件通知了,又看了一下nagios的日誌,我service的狀態變化是出在週六,也就是從warning轉變成critical就不發郵件了,問題可能出在服務報警通知那部分,於是先看了一下我定義的所有服務和主機的模板檔案,內容如下
# vi genericdef.cfg
1 define host{
2 name generic-host
3 check_period 24x7
4 notifications_enabled 1
5 event_handler_enabled 1
6 process_perf_data 1
7 retain_nonstatus_information 0
8 contact_groups admins
9 notification_interval 60
10 notification_period 24x7
11 notification_options d,u,r
12 stalking_options o,d,u
13 register 0
14 }
15
16 define service{
17 name generic-service
18 active_checks_enabled 1
19 passive_checks_enabled 1
20 notifications_enabled 1
21 event_handler_enabled 1
22 check_period 24x7
23 max_check_attempts 3
24 normal_check_interval 10
25 retry_check_interval 2
26 contact_groups admins
27 notification_options w,u,c,r
28 notification_interval 60
29 notification_period 24x7
30 register 0
31 }
從上面service定義來看,通知選項已經加入了c(CRITICAL)這個引數了,看了問題不是出在這裡。
第二個我想到的地方就是contract的配置檔案,開啟看了一下
1 define contact{
2 contact_name nagios-msn-admin
3 alias Nagios msn Admin
4 email [email protected]
5 host_notification_commands notify-host-by-msn
6 host_notification_options d,u
7 host_notification_period 24x7
8 service_notification_period 24x7
9 service_notification_options w,u,r,c //這個位置之前是沒有c
10 service_notification_commands notify-service-by-msn
11 }
12
13 define contact{
14 contact_name nagios-mail-admin
15 alias Nagios mail Admin
16 email [email protected]wenzizone.cn
17 host_notification_commands notify-host-by-email
18 host_notification_options d,u
19 host_notification_period 24x7
20 service_notification_period 24x7
21 service_notification_options w,u,r,c //這個位置之前沒有c
22 service_notification_commands notify-service-by-email
23 }
在上面的第9和21行的位置加上c之後,然後重新reload一下nagios,如果沒有報錯,說明配置更新完畢,很快蚊子又可以收到報警的郵件了。
nagios調整是一個細緻的活,看了蚊子還需要做很多的工作才行了。