#!/bin/sh # $AFresh1: alert,v 1.6 2010/02/18 19:17:42 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 local _notification=$NAGIOS_NOTIFICATIONTYPE if [ X"" != X"$NAGIOS_NOTIFICATIONCOMMENT" ]; then _notification="$_notification $NAGIOS_NOTIFICATIONCOMMENT" fi if [ X"" != X"$NAGIOS_NOTIFICATIONAUTHOR" ]; then _notification="$_notification ($NAGIOS_NOTIFICATIONAUTHOR)" fi ### HOST Descriptions ### local _short_host="$NAGIOS_HOSTNAME" local _long_host="Date/Time: $NAGIOS_LONGDATETIME $_notification Host: $NAGIOS_HOSTNAME [$NAGIOS_HOSTADDRESS] $NAGIOS_HOSTALIAS State: $NAGIOS_HOSTSTATE (for $NAGIOS_HOSTDURATION) $NAGIOS_HOSTOUTPUT 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 $_notification Host: $NAGIOS_HOSTNAME [$NAGIOS_HOSTADDRESS] $NAGIOS_HOSTALIAS State: $NAGIOS_SERVICESTATE (for $NAGIOS_SERVICEDURATION) Service: $NAGIOS_SERVICEDESC $NAGIOS_SERVICEOUTPUT 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=ACK fi _short="`echo $_state | cut -c 1-4`: $_short" _long=`echo "$_long" | awk '{ gsub(/
/,"\n") }1'` 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