All pastes #444198 Raw Edit

smcavoy

public shellscript v1 · immutable
·published 2007-04-17 07:29 UTC
rendered paste body
#!/bin/bash#source /etc/init.d/nrpe-init.shNRPELOC=/home/smcavoy/tmp/nagiosCONF=$NRPELOC/etc/alldiskcheck.confCHECKDISK="$NRPELOC"/libexec/check_diskTMPLOG=/tmp/alldiskcheck.logERRORLOG=/tmp/alldiskcheck.errWARN=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 runrm $TMPLOG &> /dev/null rm $ERRORLOG &>/dev/nullgrep -v "#" $CONF | (while read linedo  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 22else	echo "OK: All disks within thresholds"	exit 0fi