On 06.02.2013 14:55, 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.
There's a reason why environment macros are by default disabled, as they cause problems, leak memory and so on. Google for the details. Even if the command line is complicated, I still advise users to use the "normal" macros calculated on command execution, instead of pushing into your env memory. Try whatever fits best - but you've been warned. kind regards, Michael > > 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@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/icinga-users -- DI (FH) Michael Friedrich mail: michael.friedr...@gmail.com twitter: https://twitter.com/dnsmichi jabber: dnsmi...@jabber.ccc.de irc: irc.freenode.net/icinga dnsmichi icinga open source monitoring position: lead core developer url: https://www.icinga.org ------------------------------------------------------------------------------ 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/icinga-users