#!/bin/bash # the filename for the fifo is passed on the command line. # could just be defined in here, and not /etc/nagios/resource.cfg # the fifo is currently only used by this script and the eggdrop glue FIFO=$1 HOST=$NAGIOS_HOSTNAME ADDR=$NAGIOS_HOSTADDRESS TYPE=$NAGIOS_NOTIFICATIONTYPE if [ "$TYPE" == 'ACKNOWLEDGEMENT' ]; then TYPE='ACK' elif echo $TYPE | grep FLAPPING; then TYPE='FLAP' fi if [ "$NAGIOS_SERVICECHECKCOMMAND" != '' ]; then # service-level alert STATE=$NAGIOS_SERVICESTATE SERVICE="$NAGIOS_SERVICEDESC" OUTPUT="$NAGIOS_SERVICEOUTPUT" SERVICE_INFO="$SERVICE: $OUTPUT" else # host-level alert STATE="$NAGIOS_HOSTSTATE" fi printf "%-4.4s %-7.7s %-23.23s %-18.18s" $STATE $TYPE $HOST "[$ADDR]" > $FIFO if [ "$SERVICE_INFO" != '' ]; then echo " $SERVICE_INFO" > $FIFO fi if [ "$NAGIOS_NOTIFICATIONCOMMENT" != '' ]; then echo " $NAGIOS_NOTIFICATIONAUTHORNAME: $NAGIOS_NOTIFICATIONCOMMENT" > $FIFO fi