Page 1 of 1

Host notifications sending wrong $CONTACTEMAIL$

Posted: Thu Jan 23, 2020 11:56 am
by Farmer John
Service notifications work fine, this only seems to happen on host notifications.

When a host goes down, or is acknowledged, or returns to service and an alert is generated, the emails to: address, in the mail message, is being set to the Send From address defined in the Email Settings page. Not the defined $CONTACTEMAIL$ address.
Service notifications work fine and the actual $CONTACTEMAIL$ is sent to the mailer.
I am using basic notify-host-by-email and notify-service-by-email commands.

The notifications report shows the emails going to the correct address, but the mail logs do not reflect this.
Any thing I can check? The test email function works fine and the email is sent to the appropriate contact.
Profile attached
NagiosXI 5.6.10

Moderator's Note: The profile has been shared with the support team but has been removed from the public forum.

Re: Host notifications sending wrong $CONTACTEMAIL$

Posted: Thu Jan 23, 2020 2:04 pm
by scottwilkerson
The Email Settings page under Admin is only for Report sending and when using the xi_host_notification_handler & xi_service_notification_handler

If you look at your notify-host-by-email and notify-service-by-email the FROM address is being set in the command following the -r flag.

Re: Host notifications sending wrong $CONTACTEMAIL$

Posted: Thu Jan 23, 2020 3:25 pm
by Farmer John
The -r address is coming through fine, it is the contacts that seems to get dropped and substituted with the -r address.
notify commnds are below commands are below:

/usr/bin/printf "%b" "-BLAH Monitoring Systems-\nDate/Time: $LONGDATETIME$\n\nService: $SERVICEDESC$ on Host: $HOSTALIAS$\nReported $SERVICEOUTPUT$\nCurrent state is: $SERVICESTATE$\n" |
/bin/mail -r "[email protected]" -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

/usr/bin/printf "%b" "-BLAH Monitoring Systems-\nDate/Time: $LONGDATETIME$\n\nHost: $HOSTNAME$ reported $LONGHOSTOUTPUT$\nCurrent State: $HOSTSTATE\n"|
/bin/mail -r "[email protected]" -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

Why the service notification works and the host notification seems to have this issue has me puzzled.

Re: Host notifications sending wrong $CONTACTEMAIL$

Posted: Thu Jan 23, 2020 4:24 pm
by scottwilkerson
Where are you seeing that the host notifications are being sent to the -r address?

Are you sure they aren't just bouncing?

Is this every host?

I did notice this, in your host command it has this

Code: Select all

Current State: $HOSTSTATE\n"
where it should be this

Code: Select all

Current State: $HOSTSTATE$\n"
That could cause a problem

Re: Host notifications sending wrong $CONTACTEMAIL$

Posted: Thu Jan 23, 2020 4:39 pm
by Farmer John
The Current State: $HOSTSTATE\n" looks to have been the issue.
I have updated the commands to Current State: $HOSTSTATE$\n" and now the messages show the correct information and the $CONTACTEMAIL$ is now being passed. Good deal.
Thanks for your help. I believe this is solved.

Re: Host notifications sending wrong $CONTACTEMAIL$

Posted: Thu Jan 23, 2020 4:45 pm
by scottwilkerson
Farmer John wrote:The Current State: $HOSTSTATE\n" looks to have been the issue.
I have updated the commands to Current State: $HOSTSTATE$\n" and now the messages show the correct information and the $CONTACTEMAIL$ is now being passed. Good deal.
Thanks for your help. I believe this is solved.
Awesome!

Glad to help

Locking thread