Personal tools
HylaFAX The world's most advanced open source fax server

Monitor your Eicon Diva Server with Nagios

If you have an advanced ISDN card like an Eicon Diva Server PRI card, you will probably be aware it has a web interface that can, amongst many other things, indicate the status of the card and the line. Here is a Nagios plugin script that will read this data and feed it back into Nagios. You will need wget installed.

#!/bin/sh
 
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
 
PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.1 $' | sed -e 's/[^0-9.]//g'`
COOKIESFILE="/usr/lib/nagios/wgetcookies"
LINEMONFILE="/tmp/nagiosdivas.$$"
DIVAHOST="localhost"
DIVAPORT=10005
DIVAPASSWD="letmein"
 
. $PROGPATH/utils.sh
 
 print_usage() {
        echo "Usage: $PROGNAME"
}
 
print_help() {
        print_revision $PROGNAME $REVISION
        echo ""
        print_usage
        echo ""
        echo "This plugin checks hardware status of an Eicon DIVAS PRI card."
        echo ""
        support
        exit 0
}
 
case "$1" in
        --help)
                print_help
                exit 0
                ;;
        -h)
                print_help
                exit 0
                ;;
        --version)
                print_revision $PROGNAME $REVISION
                exit 0
                ;;
        -V)
                print_revision $PROGNAME $REVISION
                exit 0
                ;;
        *)
                cd /tmp
                # Log in
                wget -q --save-cookies $COOKIESFILE \
                        --timeout=7 \
                        --load-cookies $COOKIESFILE \
                        --cookies=on \
                        --delete-after \
                        http://$DIVAHOST:$DIVAPORT/login?data=$DIVAPASSWD
 
                # Now grab the line monitor stuff
                wget -q --save-cookies $COOKIESFILE \
                        --timeout=7 \
                        --load-cookies $COOKIESFILE \
                        --cookies=on \
                        -O $LINEMONFILE \
                        http://$DIVAHOST:$DIVAPORT/adapter_line_monitor1.cgi
                WGETSTATUS=$?
 
                # Figure out if we have any alarms
                for I in red blue yellow ; do
                  export ALARMVAL=`cat $LINEMONFILE | grep "var $I" | awk '{ print $4 }' | sed -e 's/;//g'`
                  export ALARM$I=$ALARMVAL
                  export ALARMSTAT=`expr $ALARMSTAT + $ALARMVAL`
                done
                CARDNAME=`cat $LINEMONFILE | grep "var adapter_name" | sed -e 's/^.*=\"//g' -e 's/\";//g'`
 
                # No more data needed, remove our temporary file
                rm $LINEMONFILE
 
                if test "$1" = "-v" -o "$1" = "--verbose"; then
                        echo "YELLOW: ${ALARMyellow}"
                        echo "RED: ${ALARMred}"
                        echo "BLUE: ${ALARMblue}"
                fi
                if test ${WGETSTATUS} -eq 1; then
                        echo "Unable to get status from http://${DIVAHOST}:${DIVAPORT}/ - check DIVAHOST,PORT and PASSWD settings in $0?"
                        exit -1
                fi
                if test ${ALARMSTAT} -eq 0; then
                        echo "DIVAS OK - $CARDNAME"
                        exit 0
                else
                        echo "DIVAS CRITICAL - Alarm detected (RED: $ALARMred. BLUE: $ALARMblue. YELLOW: $ALARMyellow)"
                        exit 2
                fi
                ;;
esac

This page was last edited on 20 April 2007, at 14:02.

Powered by MediaWiki
Attribution-ShareAlike 2.5

Project hosted by iFAX Solutions