Centos預設是安裝sendmail的,我們可以用sendmail發送郵件。
Service sendmail start
mail -s "test" [email protected] < sendmail.cf //測試郵件發送
Vi /usr/local/nagios/etc/object/contacts.cfg //添加郵箱
<a href="http://blog.51cto.com/attachment/201207/092904960.png" target="_blank"></a>
Vi /usr/local/nagios/etc/object/commad.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" | /bin/mail -s "host $HOSTSTATE$ alter for $HOSTNAME$!" $CONTACTEMAIL$ -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" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -l /var/log/sendEmail.log
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg //
檢測文法
<a href="http://blog.51cto.com/attachment/201207/093111415.png" target="_blank"></a>
Service nagios restart
本文轉自zsaisai 51CTO部落格,原文連結:http://blog.51cto.com/3402313/916711