From: root [root@ahk] Sent: Wednesday, November 13, 2002 7:10 AM To: Kaplan, Andrew H. #!/bin/bash #Configure this: #The base-directory for nagios: NAGIOSDIR=/usr/local/nagios #The directory where apan is installed APANDIR=$NAGIOSDIR/apan #The directory where Nagios plugins resides PLUGINSDIR=$NAGIOSDIR/libexec #The directory where Nagios .cfg-files resides ETCDIR=$NAGIOSDIR/etc # The directory where apans plugins resides PLUGSDIR=$APANDIR/plugs # The main config-file for apan CFGFILE=$APANDIR/apan.cfg # Path to rrdtool RRDTOOL=/usr/local/rrdtool/bin/rrdtool # Set DEBUG to 1 and define a DEBUGFILE to get debug-info from apan DEBUG=1 DEBUGFILE=/tmp/apan.debug #End Configuration #Source plugin-files for file in $PLUGSDIR/*.sh; do . $file done debug "`date` Args: $*" check=$1 host=$2 svcname=$3 time=$4 warn=$5 crit=$6 RETVAL=0 RETSTR="" #Get configuration for this service CONF=`grep "${host};${svcname};" $CFGFILE` ARGS="`echo $CONF|cut -d ";" -f 4`" NAMES=`echo $CONF|cut -d ";" -f 5` RRDFILE=`echo $CONF|cut -d ";" -f 3` if [ "$CONF" = "" ]; then ERR=1 RETVAL=3 RETSTR="No perf-definition for service." else N=0 ERR=0 DATA="$time" TEMPL="" # Make a array of DS-names for DS in $NAMES; do NAMELIST[N]=`echo $DS|cut -d ":" -f 1` N=`expr $N + 1` done N=0 ################################################################3 case $check in disk) disk ;; nt-net) nt_net ;; nt-disk) nt_disk ;; nt-smtp) nt_smtp ;; nt-load) nt_load ;; load) load ;; ping) ping ;; lxk_pages) lxk_pages ;; snmpget) snmpget ;; *) debug "Unknown service" RETSTR="Unknown Perf-service: $check" RETVAL=3 ERR=1 ;; esac fi if [ $ERR = 0 ]; then if [ `echo $TEMPL|cut -b 1-1` = ":" ]; then TEMPL=`echo $TEMPL|cut -b 2-` fi $RRDTOOL update $RRDFILE -t $TEMPL $DATA debug "Inserting '$TEMPL' , '$DATA' into $RRDFILE" else debug "Could not insert '$TEMPL' , '$DATA' into $RRDFILE" fi debug "Returning '$RETSTR' , $RETVAL" echo $RETSTR exit $RETVAL