$contactemail$ not expanded

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
mrpardijs
Posts: 2
Joined: Tue Jul 10, 2018 3:31 am

$contactemail$ not expanded

Post 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 $
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: $contactemail$ not expanded

Post 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$).
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: $contactemail$ not expanded

Post 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$).
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
mrpardijs
Posts: 2
Joined: Tue Jul 10, 2018 3:31 am

Re: $contactemail$ not expanded

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: $contactemail$ not expanded

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked