1, Configuration SendMail
Vi/etc/mail.rc
Join the line
Set Bsdcompat
Set from= Mail user name @domain.com smtp=smtp.126.com set smtp-auth-user= Mail user name smtp-auth-password= mailbox password Set Smtp-auth=login
2, check Commands.cfg
################################################################################## SAMPLE NOTIFICATION commands## These is some example notification COMMANDS. They on# your system without modification. As an example, some systems would require # you"/USR/BIN/MAILX"Instead of"/usr/bin/mail" inchThe commands below.##################################################################################'Notify-host-by-email'command Definitiondefine command{command_name notify-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 Definitiondefine command{command_name notify-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 $}
This is the correct command configuration, the most important of which is the command configuration behind/bin/mail
3, Mqueue
ls /var/spool/mqueue
This directory stores the message sending queue,
If this is full, not only will affect the program's operation, and SendMail easy to die, so when necessary to delete. 4, modify the contact address vi/usr/local/nagios/etc/objects/contacts.cfg Modify [email protected] as the address of the contact 5, check whether the sent e-mail delivered, or stranded in the mail server
/usr/lib/sendmail-bp
If the screen appears as "Mail queue is empty" information, it indicates that Mail has been sent out.
6. Send Test mail
Mail-s "Test" [email protected] <content.txt
Content.txt for message content
Nagios Configuring Mail Alerts