Page 1 of 1

Notification question

Posted: Wed Jun 25, 2014 2:20 pm
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

Re: Notification question

Posted: Wed Jun 25, 2014 2:32 pm
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.

Re: Notification question

Posted: Wed Jun 25, 2014 2:35 pm
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.

Re: Notification question

Posted: Wed Jun 25, 2014 4:58 pm
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

Re: Notification question

Posted: Wed Jun 25, 2014 8:22 pm
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