1. Installation related set-up
Yum Install Mailx sendmail*
Chkconfig SendMail on
Service SendMail Start
2. Test mail
echo "Hello World" | Mail [email protected]
3. Edit Command.cfg
# ' notify-host-by-email ' command definition
Define Command{
Command_nameNotify-host-by-email
Command_line/usr/bin/printf "%b" "* * * * Nagios *****\n\nnotification Type: $NOTIFICATIONTYPE $\nhost: $ Hostname$\nstate: $HOSTSTATE $\naddress: $HOSTADDRESS $\ninfo: $HOSTOUTPUT $\n\ndate/time: $LONGDATETIME $\n "| /bin/mail-s "* * $NOTIFICATIONTYPE $ Host Alert: $HOSTNAME $ is $HOSTSTATE $ * *" $CONTACTEMAIL $
}
# ' notify-service-by-email ' command definition
Define Command{
Command_nameNotify-service-by-email
Command_line/usr/bin/printf "%b" "* * * * Nagios *****\n\nnotification Type: $NOTIFICATIONTYPE $\n\nservice: $ Servicedesc$\nhost: $HOSTALIAS $\naddress: $HOSTADDRESS $\nstate: $SERVICESTATE $\n\ndate/time: $LONGDATETIME $\n\ Nadditional info:\n\n$serviceoutput$\n "| /bin/mail-s "* * $NOTIFICATIONTYPE $ Service Alert: $HOSTALIAS $/$SERVICEDESC $ is $SERVICESTATE $ * *" $CONTACTEMAIL $
}
4. Restart Nagios
Service Nagios Restart
5. PostScript
About the alarm send interval and so on set not to do detailed introduction
This article is from the "Linux related sharing" blog, make sure to keep this source http://2860664.blog.51cto.com/2850664/1561778
centos6.5 nagios-4.0.8 system comes with sendmail mail alarm settings