Eventhandler script


This script is designed to run as an eventhandler of a check whenever something is to be executed if the service goes from OK to CRITICAL.

Place the following code in /opt/plugins/custom/event_handler.sh

At " # Do something here " enter what the script should do.


#!/bin/bash#DEBUG=0logfile=/opt/monitor/var/eventhandler.logif [ "$DEBUG" == "1" ]; then    echo "DEBUG: $0 called with \"$0 $@\"" >> $logfilefiif [ "$1" == "-h" -o "$#" -ne "3" ]; then    echo    echo "Usage: $0 <servicestate> <servicestatetype> <addresses>"    echo    echo "       Were servicestate is the SERVICESTATE macro and servicestatetype"    echo "       is the SERVICESTATETYPE macro from Nagios."    echo    echo "       ** This script will exit on all but CRITICAL and HARD **"    echo    exit 3fiSERVICESTATE=$1SERVICESTATETYPE=$2if [ "$SERVICESTATE" != "CRITICAL" -o "$SERVICESTATETYPE" != "HARD" ]; then    echo "$0 will run for CRITICAL and HARD, not $SERVICESTATE and $SERVICESTATETYPE"    echo "$0 will run for CRITICAL : HARD, not $SERVICESTATE : $SERVICESTATETYPE." >> $logfile    exit 1fi# Do something hereecho "Eventhanlder run: $0 called with \"$0 $@\"" >> $logfile# E.O.F

The check_command for this eventhandler:

check_name:your choice

check_command: $USER1$/custom/event_handler.sh $SERVICESTATE$ $SERVICESTATETYPE$ $HOSTADDRESS$