#!/bin/bash #source /etc/init.d/nrpe-init.sh NRPELOC=/home/smcavoy/tmp/nagios CONF=$NRPELOC/etc/alldiskcheck.conf CHECKDISK="$NRPELOC"/libexec/check_disk TMPLOG=/tmp/alldiskcheck.log ERRORLOG=/tmp/alldiskcheck.err WARN=0 # while reading in config file # execute check for each line (mount point) # each line is [mount_point] [warn_thresh] [crit_thresh] # if warn output to tmplog, continue checking # if critical stop exit with critical print mount point # otherwise exit on OK or warning, warning will print # mountpoints # Cleanup from last run rm $TMPLOG &> /dev/null rm $ERRORLOG &>/dev/null grep -v "#" $CONF | ( while read line do MNTPNT=`echo $line|cut -d " " -f 1` WARNTHR=`echo $line|cut -d " " -f 2` CRITTHR=`echo $line|cut -d " " -f 3` $CHECKDISK -w "$WARNTHR"\% -c "$CRITTHR"\% -m -p $MNTPNT > $TMPLOG WHATEXIT=$? case $WHATEXIT in 0) # Within thresholds ;; 1) # exceeded warning threshold cat $TMPLOG >> $ERRORLOG ;; 2) # exceeded critical threshold cat $TMPLOG >> $ERRORLOG echo "`cat $ERRORLOG`" echo "This should not appear" exit $WHATEXIT ;; *) # something weird happened echo "UNKNOWN: Please investigate!" exit 3 ;; esac done ) # echo "out side" # if [ -s $ERRORLOG ] then echo "`cat $ERRORLOG`" exit 22 else echo "OK: All disks within thresholds" exit 0 fi