Page 1 of 1

$contactemail$ not expanded

Posted: Tue Jul 10, 2018 3:45 am
by mrpardijs
I'm using notify-service-by-mail, which is working in some cases, and not working in some other, I can't figure out why, I debugged the process by sending the command to a textfile, I notice that when the notification type is empty, also the $CONTACTEMAIL$ is not expanded.

My definition:

command_line /bin/echo Subject: $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$\n\n***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$ CONTACT EMAIL $CONTACTEMAIL$ >> /tmp/contactemail

Example: the first line is where all is working fine, I have a notification type PROBLEM, and the mailaddress is displayed, in the second example, the notification type is empty, and the contact email is $ instead if my real address. So even for the same service, sometimes the notification is working fine and sometimes not. Any ideas?

Subject: PROBLEM Service Alert: gitlab is CRITICALnn***** Nagios *****nnNotification Type: PROBLEMnnService: gitlabnHost: myhostnAddress: 192.168.5.34nState: CRITICALnnDate/Time: Tue Jul 10 10:31:19 CEST 2018nnAdditional Info:nnconnect to address 192.168.5.34 and port 8080: No route to host CONTACT EMAIL my@mail.com

Subject: Service Alert: gitlab is CRITICALnn***** Nagios *****nnNotification Type: nnService: gitlabnHost: myhostnAddress: 192.168.5.34nState: CRITICALnnDate/Time: Tue Jul 10 10:31:19 CEST 2018nnAdditional Info:nnconnect to address 192.168.5.34 and port 8080: No route to host CONTACT EMAIL $

Re: $contactemail$ not expanded

Posted: Tue Jul 10, 2018 9:52 am
by mcapra
Which version of Nagios Core are you using?

Do you also have an event handler configured anywhere that might be firing? That's Occam's razor in this case; That the second execution is not actually a notification handler, but an event handler that doesn't have access to those macros ($NOTIFICATIONTYPE$ and $CONTACTEMAIL$).

Re: $contactemail$ not expanded

Posted: Tue Jul 10, 2018 2:47 pm
by scottwilkerson
I think @mcapra is onto something here
mcapra wrote: Do you also have an event handler configured anywhere that might be firing? That's Occam's razor in this case; That the second execution is not actually a notification handler, but an event handler that doesn't have access to those macros ($NOTIFICATIONTYPE$ and $CONTACTEMAIL$).

Re: $contactemail$ not expanded

Posted: Wed Jul 11, 2018 3:46 am
by mrpardijs
That was it! I had configured my notify command as event_handler, after enabling the notification_event options it's all working now, thanks.

Re: $contactemail$ not expanded

Posted: Wed Jul 11, 2018 8:21 am
by scottwilkerson
mrpardijs wrote:That was it! I had configured my notify command as event_handler, after enabling the notification_event options it's all working now, thanks.
Great! Glad it is resolved

Locking