Different notifications for the same contact

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
agotzin
Posts: 2
Joined: Thu Jun 13, 2019 6:47 pm

Different notifications for the same contact

Post by agotzin »

I customezed notify-service-by-email command and saved it as notify-service-by-email-GDF :

/usr/bin/printf "%b" "***** Gestion de Flota*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** GDF ** $SERVICESTATE$ -- $SERVICEDESC$" $CONTACTEMAIL$

How can I send this email when a service is alerted and send the command notify-service-by-email to the same contact or Contact-group, when other services are alerted?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Different notifications for the same contact

Post by scottwilkerson »

This isn't possible how you described it, however you can write a script that does some processing to match the $SERVICEDESC$ against this service and then change the message, then use this script as the notification handler.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
agotzin
Posts: 2
Joined: Thu Jun 13, 2019 6:47 pm

Re: Different notifications for the same contact

Post by agotzin »

Thanks for your help scott wilkerson. Really, I am not a great programmer. In my work, there are different services are monitored, when they are alerted, users want to recive emails whit your subjet specific. I don't belive I have to create a diferent contact (same address email)
for each service. Thanks again.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Different notifications for the same contact

Post by scottwilkerson »

agotzin wrote:Thanks for your help scott wilkerson. Really, I am not a great programmer. In my work, there are different services are monitored, when they are alerted, users want to recive emails whit your subjet specific. I don't belive I have to create a diferent contact (same address email)
for each service. Thanks again.
Unfortunately there isn't a builtin way to change the subject for just one service without creating a custom notification handler
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked