Nagios can't send E-mail to the user when it gets alert
Posted: Mon Oct 19, 2015 1:41 am
Hello Everyone,
Here is my question:
1. Nagios is set up but still can't send email to the user via sendmail. Here is the log message got from /var/log/maillog
Oct 19 14:35:34 IFS-NAGIOS sendmail[31959]: t9J6ZYrV031959: to=$, ctladdr=nagios (500/500), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30461, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
You see to=$, that is the main point.
2. If I use sendmail manually to send email, it's ok. Like:
echo test | mail -s test [email protected]
3. If I use following command, it's ok.
/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$ **" [email protected]
4. If I use following command, it doesn't work.
/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$
Summary: $CONTACTEMAIL$ this macro doesn't work.
How to fix it ?
Reboot system --- No go
Restart Nagios --- No go
Reinstall Nagios --- No go
Reinstall system and reinstall nagios --- No go
Here is my question:
1. Nagios is set up but still can't send email to the user via sendmail. Here is the log message got from /var/log/maillog
Oct 19 14:35:34 IFS-NAGIOS sendmail[31959]: t9J6ZYrV031959: to=$, ctladdr=nagios (500/500), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30461, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
You see to=$, that is the main point.
2. If I use sendmail manually to send email, it's ok. Like:
echo test | mail -s test [email protected]
3. If I use following command, it's ok.
/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$ **" [email protected]
4. If I use following command, it doesn't work.
/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$
Summary: $CONTACTEMAIL$ this macro doesn't work.
How to fix it ?
Reboot system --- No go
Restart Nagios --- No go
Reinstall Nagios --- No go
Reinstall system and reinstall nagios --- No go