[BACK]Return to alert CVS log [TXT][DIR] Up to [local] / nagios / alert

Annotation of nagios/alert/alert, Revision 1.2

1.1       andrew      1: #!/bin/sh
1.2     ! andrew      2: # $AFresh1: alert,v 1.1 2010/02/16 16:48:01 andrew Exp $
1.1       andrew      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: ### HOST Descriptions ###
                     17:
1.2     ! andrew     18: local _short_host="$NAGIOS_HOSTNAME"
1.1       andrew     19: local _long_host="Date/Time: $NAGIOS_LONGDATETIME
1.2     ! andrew     20: $NAGIOS_NOTIFICATIONTYPE $NAGIOS_NOTIFICATIONCOMMENT
1.1       andrew     21:
1.2     ! andrew     22: Host: $NAGIOS_HOSTALIAS [$NAGIOS_HOSTADDRESS] ($NAGIOS_HOSTOUTPUT)
1.1       andrew     23: State: $NAGIOS_HOSTSTATE (for $NAGIOS_HOSTDURATION)
                     24:
                     25: https://stats.redrivernet.com/CGi-bin/nagios/extinfo.cgi?type=1&host=$NAGIOS_HOSTNAME
                     26: "
                     27:
                     28: ### SERVICE Descriptions ###
                     29:
1.2     ! andrew     30: local _short_svc="$NAGIOS_HOSTNAME $NAGIOS_SERVICEDESC ($NAGIOS_SERVICEOUTPUT)"
1.1       andrew     31: local _long_svc="Date/Time: $NAGIOS_LONGDATETIME
1.2     ! andrew     32: $NAGIOS_NOTIFICATIONTYPE $NAGIOS_NOTIFICATIONCOMMENT
1.1       andrew     33:
1.2     ! andrew     34: Service: $NAGIOS_SERVICEDESC ($NAGIOS_SERVICEOUTPUT)
1.1       andrew     35: Host: $NAGIOS_HOSTALIAS ($NAGIOS_HOSTADDRESS)
1.2     ! andrew     36: State: $NAGIOS_HOSTSTATE (for $NAGIOS_HOSTDURATION)
1.1       andrew     37:
                     38: https://stats.redrivernet.com/cgi-bin/nagios/extinfo.cgi?type=2&host=$NAGIOS_HOSTNAME&service=`echo $NAGIOS_SERVICEDESC | sed -e 's/ /+/g'`
                     39: "
                     40:
                     41: ### Actions ###
                     42:
1.2     ! andrew     43: local _state
1.1       andrew     44: local _short
                     45: local _long
                     46: case $_type in
                     47:        HOST)
1.2     ! andrew     48:         _state=$NAGIOS_HOSTSTATE
1.1       andrew     49:                _short=$_short_host
                     50:                _long=$_long_host
                     51:                ;;
                     52:        SERVICE)
1.2     ! andrew     53:         _state=$NAGIOS_SERVICESTATE
1.1       andrew     54:                _short=$_short_svc
                     55:                _long=$_long_svc
                     56:                ;;
                     57:        *)
                     58:                echo "Unknown type $_type"
                     59:                exit 3
                     60:                ;;
                     61: esac
                     62:
1.2     ! andrew     63: if [ X"$NAGIOS_NOTIFICATIONTYPE" == X"ACKNOWLEDGEMENT" ]; then
        !            64:     _state=$NAGIOS_NOTIFICATIONTYPE
1.1       andrew     65: fi
                     66:
1.2     ! andrew     67: _short=$_state: $_short
1.1       andrew     68:
                     69: case $_method in
                     70:        mail)
                     71:                echo "$_long" | /usr/bin/mail -s "$_short" $_contact
                     72:                ;;
                     73:        qpage)
                     74:                echo "$_short" | /usr/local/bin/page_somehow $_contact
                     75:                ;;
                     76:        jabber)
                     77:                echo "$_long" | /usr/local/libexec/nagios/eventhandlers/alert_jabber $_contact
                     78:                ;;
                     79:        *)
                     80:                echo "Unknown method $_method"
                     81:                exit 3
                     82:                ;;
                     83: esac

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>