I'm trying to get an event handler enabled on some of our "non-critical" hosts that automatically acknowledges them if they go down. I.e hosts that we want to monitor but don't need to be alerted on our maps and notifications when they go down.
Currently I have the host defined as below;
Code: Select all
define host{
use B-Hosts,host-pnp
host_name TEST_PRINTER
alias TEST_PRINTER
address 172.21.141.29
check_command check-host-alive
hostgroups printers
icon_image printer.png
event_handler auto-acknowledge
}
Code: Select all
define command{
command_name auto-acknowledge
command_line $USER1$/auto-acknowledge.sh $HOSTSTATE$ $HOSTSTATETYPE$ $HOSTATTEMPT$ $HOSTNAME$
}
Code: Select all
#!/bin/sh
#
# Event handler script for acknowledging non critical hosts.
#
#
# What state is the Host in?
case "$1" in
UP)
;;
UNREACHABLE)
;;
DOWN)
case "$2" in
SOFT)
case "$3" in
1)
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] ACKNOWLEDGE_HOST_PROBLEM;$4;2;1;1;Autobot;Non-critical host, outage acknowledged\n" $now > $commandfile
;;
esac
;;
HARD)
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] ACKNOWLEDGE_HOST_PROBLEM;$4;2;0;1;Autobot;Non-critical host, outage acknowledged\n" $now > $commandfile
;;
esac
;;
esac
exit 0
Thanks