#!/bin/sh # $AFresh1: alert,v 1.3 2010/02/16 17:18:31 andrew Exp $ local _type=$1 local _method=$2 local _contact=$3 if [ X"" == X"$_type" -o $"" == X"$_method" -o X"" == X"$_contact" ]; then echo "Usage: $0: " echo " type is HOST or SERVICE" echo " method is mail, qpage or jabber" echo " contact is the identifier to send to" exit 2 fi ### HOST Descriptions ### local _short_host="$NAGIOS_HOSTNAME" local _long_host="Date/Time: $NAGIOS_LONGDATETIME $NAGIOS_NOTIFICATIONTYPE $NAGIOS_NOTIFICATIONCOMMENT Host: $NAGIOS_HOSTALIAS [$NAGIOS_HOSTADDRESS] ($NAGIOS_HOSTOUTPUT) State: $NAGIOS_HOSTSTATE (for $NAGIOS_HOSTDURATION) https://stats.redrivernet.com/CGi-bin/nagios/extinfo.cgi?type=1&host=$NAGIOS_HOSTNAME " ### SERVICE Descriptions ### local _short_svc="$NAGIOS_HOSTNAME $NAGIOS_SERVICEDESC" local _long_svc="Date/Time: $NAGIOS_LONGDATETIME $NAGIOS_NOTIFICATIONTYPE $NAGIOS_NOTIFICATIONCOMMENT Service: $NAGIOS_SERVICEDESC ($NAGIOS_SERVICEOUTPUT) Host: $NAGIOS_HOSTALIAS ($NAGIOS_HOSTADDRESS) State: $NAGIOS_HOSTSTATE (for $NAGIOS_HOSTDURATION) https://stats.redrivernet.com/cgi-bin/nagios/extinfo.cgi?type=2&host=$NAGIOS_HOSTNAME&service=`echo $NAGIOS_SERVICEDESC | sed -e 's/ /+/g'` " ### Actions ### local _state local _short local _long case $_type in HOST) _state=$NAGIOS_HOSTSTATE _short=$_short_host _long=$_long_host ;; SERVICE) _state=$NAGIOS_SERVICESTATE _short=$_short_svc _long=$_long_svc ;; *) echo "Unknown type $_type" exit 3 ;; esac if [ X"$NAGIOS_NOTIFICATIONTYPE" == X"ACKNOWLEDGEMENT" ]; then _state=$NAGIOS_NOTIFICATIONTYPE fi _short=$_state: $_short case $_method in mail) echo "$_long" | /usr/bin/mail -s "$_short" $_contact ;; qpage) echo "$_short" | /usr/local/bin/page_somehow $_contact ;; jabber) echo "$_long" | /usr/local/libexec/nagios/eventhandlers/alert_jabber $_contact ;; *) echo "Unknown method $_method" exit 3 ;; esac