Host/service acknowledgement template?
Boeckman, Matthew
mboeckman at servicemagic.com
Wed Sep 19 16:21:07 CEST 2007
Thanks Russell, this worked like a champ. For anyone interested I made a
slight modification to the end of the file to fix the hyperlinks that
come out if the service name includes a space. For example:
perl -pi -e 's|service=mailq size|service=mailq%20size|g' $tmpfile
perl -pi -e 's|service=HTTPS check|service=HTTPS%20check|g' $tmpfile
perl -pi -e 's|service=HTTP check|service=HTTP%20check|g' $tmpfile
mail -s "$subject" "$recipient" < $tmpfile
rm -f $tmpfile
-Matthew
-----Original Message-----
From: Russell Jackson [mailto:raj at csub.edu]
Sent: Monday, September 17, 2007 1:32 PM
To: Boeckman, Matthew
Cc: nagios-users at lists.sourceforge.net
Subject: Re: [Nagios-users] Host/service acknowledgement template?
Boeckman, Matthew wrote:
> Hello list!
>
> Is there a way to configure a custom notification email for
> acknowledgements? What I have currently is a lightly modified version
> of notify-host-by-email and notify-service-by-email to include the ACK
> macro's:
>
> define command{
> command_name notify-host-by-email
> command_line /usr/bin/printf "%b" "***** Nagios
> *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost:
$HOSTNAME$\nState:
> $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\n
> $HOSTACKAUTHOR$ ack'd the alarm with message
> $HOSTACKCOMMENT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "**
> $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"
> $CONTACTEMAIL$
> }
>
> This works, but of course my text "ack'd the alarm with message"
> appears in all types of notifications with nothing in the macro
> fields, and for ACK's it works just fine.
>
> I'm wondering if there is something do-able like notify-ack-by-email
> that would only function on NOTIFICATIONTYPE=ACKNOWLEDGEMENT and thus
> use a specific printf statement about the ack. I see how I could
> configure another command definition and include it, but I'm not clear
> how to do the IF-THEN type logic.
>
> Any pointers are appreciated, thanks!
>
I use an external sh script (see attachment). It's called without
arguments (taking advantage of nagios 2.x exporting of macros to the
environment) like so:
define command {
command_name notify-by-email
command_line $USER3$/notify-by-email.sh }
I use the same script for all notification and generate the contents
based on the presence of certain macros -> env variables. The script
could probably be better, but it's working for me ATM.
--
Russell A. Jackson <raj at csub.edu>
Network Analyst
California State University, Bakersfield
Don't make a big deal out of everything; just deal with everything.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list