天天看點

nagios監控使用139郵箱報警

 139郵箱申請:http://mail.10086.cn/

  http://caspian.dotconf.net/menu/Software/SendEmail/ 1.下載下傳 wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz   2.編譯安裝 tar xvzf sendEmail-v1.56.tar.gz cd sendEmail-v1.56/ cp sendEmail /usr/local/bin chmod +x /usr/local/bin/sendEmail   3.測試郵件發送: /usr/local/bin/sendEmail -f [email protected] -t [email protected] -s smtp.163.com -u “send by hugwww” -xu hugwww -xp gaojinbo.com -m “郵件發送成功,good”   4.配置Nagios cd /usr/local/nagios/etc/objects vi commands.cfg   建議,nagios報警盡量不要使用本機sendmail,在大網站注冊個免費郵箱發去吧,也減少了很多麻煩,比如sendmail問題導緻的報警不能及時到達 以下為command中定義的發郵件指令,根據自己的實際情況修改 command.cfg中加入 define command{         command_name    notify-host-by-sendEmail         command_line    /usr/bin/printf "%b" "***** Nagios-BJ *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.163.com -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -xu ceshi -xp xxxxxxxx -l /var/log/sendEmail.log         }   define command{         command_name    notify-service-by-sendEmail         command_line    /usr/bin/printf "%b" "***** Nagios-BJ *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.163.com -u  "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" -xu ceshi -xp xxxxxxxx -l /var/log/sendEmail.log         }    解釋:  -f 表示發送者的郵箱  -t 表示接收者的郵箱  -s 表示SMTP伺服器的域名或者ip  -u 表示郵件的主題  -xu 表示SMTP驗證的使用者名  -xp 表示SMTP驗證的密碼(注意,這個密碼貌似有限制,例如我用d!5neyland就不能被正确識别)  -m 表示郵件的内容  如果你不帶-m參數的話,就會提示你自行輸入     5.定義聯系人 vi contacts.cfg define contact { contact_name                    admin alias                           system admin host_notification_period        24×7 service_notification_period     24×7 host_notification_options       d,r service_notification_options    w,u,c,r service_notification_commands   notify-service-by-sendEmail host_notification_commands      notify-host-by-sendEmail email                           [email protected] pager                           [email protected] }   測試故障時是否能夠觸發短信報警 /usr/local/139/sendsms.sh “nagios Host alert”

轉載于:https://blog.51cto.com/lidzh1109/831059