[icinga-users] notification command configuration

Simon Oosthoek soosthoek at nieuwland.nl
Wed Feb 6 14:55:28 CET 2013


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




More information about the icinga-users mailing list