Email notifications not working


I am configured nagios on FreeBSD servers before without problems, but am now trying on a Mandiva box and can’t get email notifications to work.

My host-notify-by-email command is defined like this:

define command{
command_name host-notify-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 “Host $HOSTSTATE$ alert for $HOSTNAME$” $CONTACTEMAIL$
my address is entered in contacts.cfg.

If I type /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 “Host $HOSTSTATE$ alert for $HOSTNAME$” [email protected]

on the command line I get an email, without values for the variables of course.

All hosts and services are configured to send notifications for warnings, down, critical and unknown.

The nagios log shows **Host Notification[05-04-2006 10:19:45] HOST NOTIFICATION: cdiaz;… ** when an alert should be sent.

Any ideas?

“The nagios log shows Host Notification[05-04-2006 10:19:45] HOST NOTIFICATION: cdiaz;… when an alert should be sent.”

So what’s the problem? Did you not get the notification or something? If it worked in the command line, and won’t in nagios, then my guess is, that you need to su - nagios and try the command line again. It might fail as user nagios, and tell you WHY it failed.

I did not get the notification even though the nagios log shows the notification being generated.

When I su to the nagios user and run the command from the command line, the email goes through.

Your contact may not want to be notified, so no message is sent. Perhaps your contact is not even a contact for the failed service. It could be many things. Double check your files/settings. I’m sure you missed something.

If I see this: HOST NOTIFICATION: cdiaz;All4Ed;UP;host-notify-by-email;TCP OK - 0.033 second response time on port xxxx in the nagios log, doesn’t that mean that it tried to notify user cdiaz? That user is in the contact group for the host, has notify times of 24x7 and sending as any user including the nagios user to that email account from the command line works.

su - nagios
type mail then hit enter.
read the mail for user nagios, and you may see why the mail is not being delivered.