Nagios郵件報警


Nagios郵件報警

准備

yum - y install ntp        ntpdate time.windows.com   同步時間,否則無法發送郵件

yum - y remove postfix                                  由於系統默認安裝了postfix 所以先卸載掉 

安裝sendmail

yum -y install sendmail mail          安裝sendmail mail

service sendmail start                       啟動sendmail

echo "Hello World" | /bin/mail -s test darker_darker@163.com  發送測試郵件

編輯sendmail權限

sendmail 默認一般只讓root使用,root用戶無法訪問 /var/spool/mqueue

chmod 2755 /usr/sbin/sendmail.sendmail           

chmod a+rwx /var/spool/mqueue

service sendmail restart                                 重啟sendmail

nagios配置文件

vim /usr/local/nagios/etc/objects/contacts.cfg

emaildarker_darker@163.com  darker_darker@139.com

修改email為自己的郵箱  可以空格后添加多個郵箱

 

 

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

service nagios restart

然后測試nagios配置文件是否正常,重啟nagios

service httpd stop                停止被監控端Web服務

 

郵箱報警

163139同時收到了Mysql服務down

Mysql恢復后會發送郵件通知

其他參數

vim /usr/local/nagios/etc/objects/templates.cfg                 編輯模版

 

normal_check_interval

此選項是用來設置服務檢查時間間隔,也就是說,nagios這一次檢查和下一次檢查之間所隔的時間,這里是10分鍾。  一般設置為5分鍾

notification_interval      60#在服務出現異常后,故障一直沒有解決,nagios再次對使用者發出通知的時間。單位是分鍾。如果你認為,所有的事件只需要一次通知就夠了,可以把這里的選項設為0         一般設置10分鍾

 

 

報警延遲是由於host or service狀態不穩定,nagios稱之為flapping state

nagios的主配置文件nagios.cfg中,有如下內容:

enable_flap_detection=0#雖然文檔里說默認是0,但實際為1.改為0之后就解決了flapping state,並且解決了臨時suppress notifications的問題


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM