Plugin:check snmp hpux swap


 * 1) !/bin/sh


 * 1) check_snmp_hpux ##############
 * 2) Version : 0.1
 * 3) Date :  November 27 2008
 * 4) Author  : Alain van der Heiden & Remco Hage
 * 5) With help from: Albert-Jan Stevens
 * 6) Help : http://www.realopenit.nl
 * 7) Licence : GPL - http://www.fsf.org/licenses/gpl.txt
 * 8) help : ./check_snmp_hpux_swap
 * 1) help : ./check_snmp_hpux_swap
 * 1) help : ./check_snmp_hpux_swap

PROGNAME=$0 DEPTH=2    # Achter komma bij percentage berekening HOSTNAME="$1" WARNING=$2 CRITICAL=$3 COMMUNITY=$4

print_help { echo $PROGNAME echo "" echo "Usage: $PROGNAME   " echo "" echo "This plugin checks the total and freememory on HP-UX servers." echo "Tests if the swap is less then and " echo "" exit 0 }

case "$1" in	--help)		print_help		exit 0		;;	-h) print_help exit 0 ;;	--version)  		echo $PROGNAME v0.1		exit 0		;;	-V) echo $PROGNAME v0.1 exit 0 ;;	*)		FREESWAP=`snmpwalk -v 2c -c $COMMUNITY "$HOSTNAME" -Oq -Ov .1.3.6.1.4.1.11.2.3.1.1.12.0`		TOTALSWAP=`snmpwalk -v 2c -c $COMMUNITY "$HOSTNAME" -Oq -Ov .1.3.6.1.4.1.11.2.3.1.1.11.0`		# echo $FREESWAP		#echo $TOTALSWAP		## Conversion KB -> MB

FREESWAP=$(echo "scale=0 ; $FREESWAP/1024"| bc) TOTALSWAP=$(echo "scale=0 ; $TOTALSWAP/1024"| bc)

##echo $FREESWAP ##echo $TOTALSWAP

## Percentage calculation

CALDEPTH=$(($FREESWAP*100)) PERCENT=$(echo "scale=$DEPTH ; $CALDEPTH/$TOTALSWAP"| bc) INTPERCENT=$(echo "scale=0 ; $CALDEPTH/$TOTALSWAP"| bc)

echo "Swap: $TOTALSWAP MB (100%) / $FREESWAP MB ($PERCENT%)|size=$TOTALSWAP swap=$FREESWAP;0;$TOTALSWAP"

if [ $CRITICAL -ge $INTPERCENT ]; then exit 2 elif [ $WARNING -ge $INTPERCENT ]; then exit 1 else exit 0 fi ;; esac