Plugin:check snmp hpux cpu


 * 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 --version) echo $PROGNAME v0.1 exit 0 -V) echo $PROGNAME v0.1 exit 0 USERCPU=`snmpwalk -v 2c -c $COMMUNITY "$HOSTNAME" -Oq -Ov .1.3.6.1.4.1.11.2.3.1.1.13.0` SYSCPU=`snmpwalk -v 2c -c $COMMUNITY "$HOSTNAME" -Oq -Ov .1.3.6.1.4.1.11.2.3.1.1.14.0` IDLECPU=`snmpwalk -v 2c -c $COMMUNITY "$HOSTNAME" -Oq -Ov .1.3.6.1.4.1.11.2.3.1.1.15.0` NICECPU=`snmpwalk -v 2c -c $COMMUNITY "$HOSTNAME" -Oq -Ov .1.3.6.1.4.1.11.2.3.1.1.16.0`
 * 1) Conversion KB -> MB


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

TOTALCPU=$(echo "scale=0 ; $USERCPU + $SYSCPU + $IDLECPU + $NICECPU" | bc)
 * 1) Percentage calculation

USERCPUPCT=$(echo "scale=0 ; $(($USERCPU*100))/$TOTALCPU"| bc) SYSCPUPCT=$(echo "scale=0 ; $(($SYSCPU*100))/$TOTALCPU"| bc) IDLECPUPCT=$(echo "scale=0 ; $(($IDLECPU*100))/$TOTALCPU"| bc) NICECPUPCT=$(echo "scale=0 ; $(($NICECPU*100))/$TOTALCPU"| bc)
 * 1) CALDEPTH=$(($FREESWAP*100))
 * 2) PERCENT=$(echo "scale=$DEPTH ; $CALDEPTH/$TOTALCPU"| bc)
 * 3) INTPERCENT=$(echo "scale=0 ; $CALDEPTH/$TOTALCPU"| bc)

echo "CPU: Idle = $IDLECPUPCT % |usercpu=$USERCPUPCT syscpu=$SYSCPUPCT idlecpu=$IDLECPUPCT nicecpu=$NICECPUPCT;0;100" echo "CPU: Idle = $IDLECPUPCT % |usercpu=$USERCPUPCT syscpu=$SYSCPUPCT idlecpu=$IDLECPUPCT nicecpu=$NICECPUPCT;0;100"

esac
 * 1) if [ $CRITICAL -ge $INTPERCENT ]; then
 * 2)        exit 2
 * 3) elif [ $WARNING -ge $INTPERCENT ]; then
 * 4)        exit 1
 * 5) else
 * 6)        exit 0
 * fi