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

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
houjun19830610
Posts: 1
Joined: Mon Oct 19, 2015 1:31 am

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

Post 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
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

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

Post 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)
Former Nagios Employee.
me.
Ticcio
Posts: 6
Joined: Tue Oct 20, 2015 10:30 am

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

Post 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.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

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

Post by hsmith »

If that is the contact you're using for that service check, yeah, that is where it will take it from.
Former Nagios Employee.
me.
Locked