Annotation of nagios/alert/alert, Revision 1.1
1.1 ! andrew 1: #!/bin/sh
! 2: # $AFresh1$
! 3: local _type=$1
! 4: local _method=$2
! 5: local _contact=$3
! 6:
! 7: if [ X"" == X"$_type" -o $"" == X"$_method" -o X"" == X"$_contact" ]; then
! 8: echo "Usage: $0: <type> <method> <contact>"
! 9: echo " type is HOST or SERVICE"
! 10: echo " method is mail, qpage or jabber"
! 11: echo " contact is the identifier to send to"
! 12: exit 2
! 13: fi
! 14:
! 15:
! 16:
! 17: ### HOST Descriptions ###
! 18:
! 19: local _short_host="$NAGIOS_HOSTSTATE: $NAGIOS_HOSTNAME"
! 20: local _long_host="Date/Time: $NAGIOS_LONGDATETIME
! 21: Notification Type: $NAGIOS_NOTIFICATIONTYPE
! 22:
! 23: Host: $NAGIOS_HOSTALIAS ($NAGIOS_HOSTADDRESS)
! 24: State: $NAGIOS_HOSTSTATE (for $NAGIOS_HOSTDURATION)
! 25:
! 26: https://stats.redrivernet.com/CGi-bin/nagios/extinfo.cgi?type=1&host=$NAGIOS_HOSTNAME
! 27: "
! 28:
! 29: ### SERVICE Descriptions ###
! 30:
! 31: local _short_svc="$NAGIOS_SERVICESTATE: $NAGIOS_HOSTNAME $NAGIOS_SERVICEDESC ($NAGIOS_SERVICEOUTPUT)"
! 32: local _long_svc="Date/Time: $NAGIOS_LONGDATETIME
! 33: Notification Type: $NAGIOS_NOTIFICATIONTYPE
! 34:
! 35: Service: $NAGIOS_SERVICEDESC
! 36: Host: $NAGIOS_HOSTALIAS ($NAGIOS_HOSTADDRESS)
! 37: State: $NAGIOS_SERVICESTATE (for $NAGIOS_SERVICEDURATION)
! 38:
! 39: https://stats.redrivernet.com/cgi-bin/nagios/extinfo.cgi?type=2&host=$NAGIOS_HOSTNAME&service=`echo $NAGIOS_SERVICEDESC | sed -e 's/ /+/g'`
! 40: "
! 41:
! 42: ### Actions ###
! 43:
! 44: local _additional_vars=NOTIFICATIONCOMMENT
! 45: local _short
! 46: local _long
! 47: case $_type in
! 48: HOST)
! 49: _short=$_short_host
! 50: _long=$_long_host
! 51: _additional_vars="$_additional_vars HOSTOUTPUT HOSTACKCOMMENT"
! 52: ;;
! 53: SERVICE)
! 54: _short=$_short_svc
! 55: _long=$_long_svc
! 56: _additional_vars="$_additional_vars SERVICEOUTPUT SERVICEACKCOMMENT"
! 57: ;;
! 58: *)
! 59: echo "Unknown type $_type"
! 60: exit 3
! 61: ;;
! 62: esac
! 63:
! 64: local _add
! 65: local _a
! 66: for _a in $_additional_vars; do
! 67: local _val
! 68: eval _val=\${NAGIOS_${_a}}
! 69: if [ X"" != X"$_val" ]; then
! 70: _add="$_add\n$_val"
! 71: fi
! 72: done
! 73:
! 74: if [ X"" != X"$_add" ]; then
! 75: _long="$_long\nAdditional Info: $_add"
! 76: fi
! 77:
! 78:
! 79: case $_method in
! 80: mail)
! 81: echo "$_long" | /usr/bin/mail -s "$_short" $_contact
! 82: ;;
! 83: qpage)
! 84: echo "$_short" | /usr/local/bin/page_somehow $_contact
! 85: ;;
! 86: jabber)
! 87: echo "$_long" | /usr/local/libexec/nagios/eventhandlers/alert_jabber $_contact
! 88: ;;
! 89: *)
! 90: echo "Unknown method $_method"
! 91: exit 3
! 92: ;;
! 93: esac
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>