Notification question

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
Ipeek
Posts: 2
Joined: Wed Jun 25, 2014 2:00 pm

Notification question

Post by Ipeek »

Hello all I hope this is the correct place to put this question.

I'm pretty new at Nagios and would like to know if there is a way to set a custom notification template for a specific service alert that will email to specific user(s).

eg
My computer goes down -> IsaacCompDownEmailTemplate -> Email Isaac only

Let me know if that does not make sense I can give another example. Clearly this wouldn't be for my specific machine but for a service on one of our servers.

Thanks,

Isaac
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Notification question

Post by eloyd »

Yes, this is part of the basic functionality of Nagios. You will want to start with http://nagios.sourceforge.net/docs/3_0/ ... tions.html on how notifications work, and then you will want to use a service_notification_commands and/or host_notification_commands for the specific contact, to use a different notification generation technique than your "normal" notification. Those attributes are part of the contact, so you'll want to read up on http://nagios.sourceforge.net/docs/3_0/ ... ml#contact.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Notification question

Post by tmcdonald »

Currently you probably have something in commands.cfg that looks like this:

Code: Select all

define command {
       command_name                     notify-host-by-email
       command_line                     /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
You could make a similar one like this:

Code: Select all

define command {
       command_name                     notify-isaac-by-email
       command_line                     /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
then just use notify-isaac-by-email for the services you want the custom email on. If you want to have a single service send a normal email to some people but a specialized email to you only, you would need to write a wrapper script that checks to see who is being notified and take action accordingly. Still doable, just a bit more work.
Former Nagios employee
Ipeek
Posts: 2
Joined: Wed Jun 25, 2014 2:00 pm

Re: Notification question

Post by Ipeek »

Thanks for the quick replies.

I went in and added the notify-isaac-pc-down section. That was easy... The part im having trouble with is how do I directly assign that notify to a specific host or service.

I need it to send that template to the "overnightreps" Contact when the service "Check_Asterisk_CDR" fails or goes down. Im just not sure where to put the "check_asterisk_cdr 1(enable)"

Does that make sense? I guess I don't know if I have to add a line to a service, host, service group, contact etc.. for nagios to know that when cdrs go down to email the over night reps and me. I don't need the reps getting alerts for everything else.

Thanks,
Isaac
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Notification question

Post by eloyd »

To quote myself:
then you will want to use a service_notification_commands and/or host_notification_commands for the specific contact, to use a different notification generation technique than your "normal" notification. Those attributes are part of the contact, so you'll want to read up on http://nagios.sourceforge.net/docs/3_0/ ... ml#contact.
  • First, you need to create the specific notification command. By your posting, it looks like you've done that.
    Then you need to modify your "issac" contact to use a service_notification_commands and/or host_notification_commands of your new "notify-isaac-by-email" command.
    Then make sure your service and/or hosts use the "issac" contact
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
Locked