[icinga-users] notification command configuration

John Sellens jsellens at syonex.com
Wed Feb 6 15:14:02 CET 2013


A year or so ago I came to the same conclusion (I happen to be a Nagios
user, but the problem is the same).

I wrote a tool that I called "genoa" for "GEneric NOtification
Author/Arranger/Artist" which lets you set up templates for what you want
your messages to look like, and does environment variable substitution.
The templates are searched for based on host, service, etc.

So, just as you propose, the notification command line looks like
    command_line genoa -s
to send mail, or
    command_line genoa -p
to send pages.

I also wrote a notification tool I called "tellitto" which is meant for
use if you have multiple ways to send pager notifications, and which
"genoa -p" will use.

I'll invite you to have a look
    http://www.syonex.com/resources/software/
    http://exchange.nagios.org/directory/Addons/Notifications/genoa/details
    http://exchange.nagios.org/directory/Addons/Notifications/tellitto/details
and would welcome any feedback.

As for forcing Icinga (or whatever) to send a notification, just unplug
something :-)  Or, if that's not an option, you could add a check that is
bound to fail e.g. check for a TCP port that you know is closed.

Hope this is helpful - cheers!

John




On Wed, Feb 06, 2013 at 02:55:28PM +0100, Simon Oosthoek wrote:
| Hi all
| 
| I'm wondering why notification comand_line's are so complicated (i.e. 
| long and hard to read).
| Most if not all relevant macro's are available as environment variables, 
| according to the documentation 
| http://docs.icinga.org/latest/en/macrolist.html
| 
| Wouldn't it be much easier to define a script to handle the sending of a 
| notification (doesn't matter what type)? The script could then take the 
| information from ICINGA_* variables and if one isn't exported, request 
| it from the commandline.
| 
| Then the script can use all that to produce an e-mail or sms or whatever.
| 
| 
| e.g. instead of:
| command_line    /usr/bin/printf "%b" "$SHORTDATETIME$ - 
| Info:\n\n$HOSTOUTPUT$\n\n$NOTIFICATIONTYPE$ - Host $HOSTNAME$ is 
| $HOSTSTATE$\n\n(Address: $HOSTADDRESS$ Displayname: 
| $HOSTDISPLAYNAME$)\n\nNotes: $NOTIFICATIONAUTHOR$ 
| $NOTIFICATIONCOMMENT$\n$HOSTNOTESURL$\n\nUrl:\nhttp://ICINGAHOST/icinga/cgi-bin/extinfo.cgi?type=1&host=$HOSTNAME$\n\n" 
| | /usr/bin/mail -s "$NOTIFICATIONTYPE$ - $HOSTNAME$ is $HOSTSTATE$" 
| $CONTACTEMAIL$
| 
| why not:
| command_line	$USER1$/send_email
| 
| with /usr/local/icinga/libexec/send_email:
| #!/bin/bash
| 
| if [[ -z "$ICINGA_CONTACTEMAIL" ]]; then
|          exit 1
| fi
| 
| mutt -s "$ICINGA_NOTIFICATIONTYPE - $ICINGA_HOSTNAME is 
| $ICINGA_HOSTSTATE" "$ICINGA_CONTACTEMAIL" <<EOF
| 
| Info: $ICINGA_HOSTOUTPUT
| 
| $ICINGA_NOTIFICATIONTYPE - Host $ICINGA_HOSTNAME is $ICINGA_HOSTSTATE
| 
| Address: $ICINGA_HOSTADDRESS
| Displayname: $ICINGA_HOSTDISPLAYNAME
| 
| Notes: $ICINGA_NOTIFICATIONAUTHOR $ICINGA_NOTIFICATIONCOMMENT
| $ICINGA_HOSTNOTESURL
| 
| Url: 
| http://ICINGAHOST/icinga/cgi-bin/extinfo.cgi?type=1&host=$ICINGA_HOSTNAME"
| 
| EOF
| 
| I've yet to try it, but I was also wondering how to force icinga to send 
| a notification so I could test it...?
| 
| /Simon
| 
| ------------------------------------------------------------------------------
| Free Next-Gen Firewall Hardware Offer
| Buy your Sophos next-gen firewall before the end March 2013 
| and get the hardware for free! Learn more.
| http://p.sf.net/sfu/sophos-d2d-feb
| _______________________________________________
| icinga-users mailing list
| icinga-users at lists.sourceforge.net
| https://lists.sourceforge.net/lists/listinfo/icinga-users




More information about the icinga-users mailing list