acknowledge triggers a script
Jonathan Angliss
jon at netdork.net
Wed May 11 05:44:53 CEST 2011
On 05/10/11 14:20, dave stern - e-mail.pluribus.unum wrote:
> We have an interesting need. When a particular service goes red on our
> Nagios 3.2.1 server, we'd like to be able to click on "Acknowledge this
> service problem" and have that activate a local script. Anyone have any
> idea how this can be accomplished?
I'd do something similar to what Ryan Davis suggested. He was right on
the money with looking at the NOTIFICATIONTYPE macro. Create a custom
script that accepts whatever arguments you need to handle whatever it is
you want to do. Check the macros list [1] and see what you have
available at notification time. I'm just going to pass in the ack
author, type, host, and service (if it's a service notification). This
is mostly pseudo-bash, but gives you an idea...
===8<---------
#!/bin/sh
HOST=$1
AUTHOR=$2
TYPE=$3
SVC=$4
case $TYPE in
ACK*)
echo "$HOST;$AUTHOR;$SVC" > /tmp/ack_log.txt
;;
esac
# If we want to handle other conditions in the same script, add to
# the case statement
====8<--------
Then we need to define commands:
define command {
command_name host_notify_ack_handle
command_line $USER1$/notify_ack_handle $HOSTNAME$ \
$HOSTACKAUTHOR$ $NOTIFICATIONTYPE$
}
define command {
command_name svc_notify_ack_handle
command_line $USER1$/notify_ack_handle $HOSTNAME$ \
$SERVICEACKAUTHOR$ $NOTIFICATIONTYPE$ \
$SERVICEDESC$
}
I wrapped the lines with \ for readability, should all be on one line.
And finally, a contact that you add to the host/service that you want
your custom notification handler to work on...
define contact {
use generic-contact
service_notification_command svc_notify_ack_handle
host_notification_command host_notify_ack_handle
host_notification_period 24x7
host_notification_options d,u,r,f
service_notification_period 24x7
service_notification_options w,u,c,r,f
}
This does execute on every notification type, but because of the case
statement in the script, only does anything useful when the notification
type is ACKNOWLEDGEMENT.
[1]: http://nagios.sourceforge.net/docs/3_0/macrolist.html
Hope that gives you some ideas to play with. I'd love to see what you
come up with if you can post a follow up.
--
Jonathan angliss
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
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