Page 1 of 1

Different Notification E-mail for Just One Service

Posted: Mon Nov 19, 2012 5:09 am
by gshergill
Hi Nagios Support,

I was wondering about adding a custom notification for a specific service.

The only way I can find to implement this is to create a notification command in CCM with the required text, then create a new contact and assign him the new host notification command under Alerts.

Is there any way to create a custom notification every time a specific service enters a non-OK state from the service definition itself?

I didn't think there would be as it seems the contact handles the notification sent rather than the service (unless you send a custom notification, but that's not automatic right?).

Hope that made sense, please ask if you require some further clarification.

Thank you.

Kind Regards,

Gary Shergill

Re: Different Notification E-mail for Just One Service

Posted: Mon Nov 19, 2012 2:42 pm
by scottwilkerson
How about creating a custom command as a "Misc Command" and just adding it as an event handler for this service?

Re: Different Notification E-mail for Just One Service

Posted: Tue Nov 20, 2012 6:42 am
by gshergill
Hi scottwilkerson,

Thanks for the response.

I've added a new misc_command named custom-explorer:

/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\nYou are Logged In\n\n$SERVICEOUTPUT$" | /bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

I went to the service > Check Settings > Event Handler and selected "custom-explorer" and set the radio button under it to "On" (was on "Skip").

I then forced the service into CRITICAL to receive the error, but no custom notification was received (just the standard one).

I tried turning off notifications and repeating the error but no notifications at all were sent.

Checking the Notifications tab to see which are sent, there is only ever the standard one being sent.

Am I missing a configuration step for the event handler? Or is the command wrong?

Thank you.

Kind Regards,

Gary Shergill

Re: Different Notification E-mail for Just One Service

Posted: Tue Nov 20, 2012 11:19 am
by scottwilkerson
Ok, this method will not work for sending to a contact, $CONTACTEMAIL$ will not be defined (but you could put an actual email address in it's place).

I thought you just wanted an additional custom message sent to a specific address...

I don't believe there would be any way to do this without setting up specific contact as you had mentioned.

Re: Different Notification E-mail for Just One Service

Posted: Wed Nov 21, 2012 5:24 am
by gshergill
Hi scottwilkerson,

Considering we only need one user to receive the mail about the service, changing $CONTACTEMAIL$ to the email address works perfectly.

If in the future additional personnel are required, I will simply create a service specific contact, but this seems to be working good for now.

One thing to note is that it performs the event_handler command every time a check is performed before it reaches a hard state. Once it is in this state it no longer performs the event_handler.
To get around this I simply increased the max attempts and added a longer delay on the retry_interval.

After snapshotting, one thing I attempted was to add multiple event_handler commands to the service through the command line (to see if I could get it working for multiple users without creating one contact each, but instead multiple commands with different emails).

It seems the line;

Code: Select all

event_handler       event-handler-1, event-handler-2
does not work (it attempts to look for a command defined as "event-handler-1, event-handler-2").

Adding them on seperate lines;

Code: Select all

event_handler       event-handler-1
event_handler       event-handler-2
caused the email to only be sent out to the mail defined in "event-handler-2".

Thanks again for the help, it is appreciated.

Kind Regards,

Gary Shergill

Re: Different Notification E-mail for Just One Service

Posted: Wed Nov 21, 2012 2:10 pm
by scottwilkerson
this is what I would have done.

I'm going to have to look into why you cannot run multiple commands...

Re: Different Notification E-mail for Just One Service

Posted: Thu Nov 22, 2012 11:01 am
by gshergill
Hi scottwilkerson,
scottwilkerson wrote:I'm going to have to look into why you cannot run multiple commands...
Thank you, I appreciate the help.

Kind Regards,

Gary Shergill