Page 1 of 1

Nagios can't send E-mail to the user when it gets alert

Posted: Mon Oct 19, 2015 1:41 am
by houjun19830610
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

Re: Nagios can't send E-mail to the user when it gets alert

Posted: Mon Oct 19, 2015 9:48 am
by hsmith
Going to need some information:
  • What version of Nagios are you using?
  • What OS are you installing it on?
  • How are you installing Nagios? (Source/repository)

Re: Nagios can't send E-mail to the user when it gets alert

Posted: Wed Oct 21, 2015 4:10 am
by Ticcio
Did you change the email in contacts.cfg?

Code: Select all

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 THIS TO YOUR EMAIL ADDRESS ******
        }
Nagios takes the email from there if I'm not wrong.

Re: Nagios can't send E-mail to the user when it gets alert

Posted: Wed Oct 21, 2015 10:05 am
by hsmith
If that is the contact you're using for that service check, yeah, that is where it will take it from.