1. Download SendEmail
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
2, Configuration SendEmail
Tar zxvf sendemail-v1.56.tar.gz
CD sendemail-v1.56
CP Sendemail/usr/local/bin
chmod 777/usr/local/bin/sendemail
Send a test message
/usr/local/bin/sendemail-f [email protected]-t [email protected]-s Smtp.126.com-xu [email protected]-xp password -U "Nagios"-M "Tets"
Explanation:
-F means the sender's mailbox
-T indicates the recipient's mailbox
-S indicates the domain name or IP of the SMTP server
-U represents the subject of the message
-xu represents the user name for SMTP authentication
-XP represents the password for SMTP authentication
-M indicates the contents of the message
3, Configuration Contacts.cfg
Vi/usr/local/nagios/etc/objects/contacts.cfg input receive alarm email address
Define Contact{
Contact_Name nagiosadmin; Short name of user
Use Generic-contact; Inherit default values from Generic-contact template (defined above)
Alias Nagios Admin; Full name of user
email [email protected] ; <<***** change YOUR EMAIL ADDRESS ******
}
4, Configuration Commands.cfg
Vi/usr/local/nagios/etc/objects/commands.cfg
Note # ' notify-host-by-email ' command definition with # ' notify-service-by-email ' command definition for all settings
Re-enter the following:
# ' notify-host-by-email ' command definition
Define Command{
Command_name Notify-host-by-email
command_line/usr/bin/printf "%b" "* * * * Nagios *****\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.126.com-u "* * $HOSTALIAS $ is $HOSTSTATE $**"-xu [em AIL protected]-xp password-o Message-charset=utf8
}
# ' notify-service-by-email ' command definition
Define Command{
Command_name Notify-service-by-email
command_line/usr/bin/printf "%b" "* * * * Nagios *****\nnotification Type: $NOTIFICATIONTYPE $\nservice: $SERVICEDESC $\n Host: $HOSTALIAS $\naddress: $HOSTADDRESS $\nstate: $SERVICESTATE $\n\ndate/time: $LONGDATETIME $\n\nadditional info:\n $SERVICEOUTPUT $\n "| /usr/local/bin/sendemail-f [email protected]-T $CONTACTEMAIL $-S Smtp.126.com-u "* * $HOSTALIAS $/$SERVICEDESC $ is $SERVI cestate$** "-xu [email protected]-XP Password-o Message-charset=utf8
}
5. Restart Service
Nagios Mail Alarm Settings