Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
Directory
cristiano.caruso
bycristiano.caruso, June 30, 2013
I do some change to the script to support faulty Windows 2000.
Defined 2 new OID:
OID_TOTAL_W2K="HOST-RESOURCES-MIB::hrMemorySize"
OID_USED_W2K="HOST-RESOURCES-MIB::hrSWRunPerfMem"
and then added after
MEMORY_USED_ID=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME $OID_TAGMEMORY | $CMD_GREP -i 'Physical Memory\|Real Memory' | $CMD_AWK '{ print $1}' | $CMD_AWK -F "." '{print $NF}'`
this test:
if [ -z "$MEMORY_USED_ID" ]; then
MEMORY_USED_ID="0"
fi
finally, in main block:
if [ $MEMORY_USED_ID != "0" ]; then
MEMORY_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL}.${MEMORY_USED_ID}`
SWAP_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL}.${SWAP_USED_ID}`
MEMORY_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_UNIT}.${MEMORY_USED_ID}`
SWAP_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_UNIT}.${SWAP_USED_ID}`
MEMORY_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_USED}.${MEMORY_USED_ID}`
SWAP_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_USED}.${SWAP_USED_ID}`
else
# Windows 2000
MEMORY_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL_W2K}.0`
SWAP_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL}.${SWAP_USED_ID}`
MEMORY_UNIT=1024
SWAP_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_UNIT}.${SWAP_USED_ID}`
MEMORY_USED=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_USED_W2K} | cut -f 4 -d " " |paste -sd+|bc`
SWAP_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_USED}.${SWAP_USED_ID}`
fi
Maybe isn't best way, but t works.
Regards
Cristiano
Defined 2 new OID:
OID_TOTAL_W2K="HOST-RESOURCES-MIB::hrMemorySize"
OID_USED_W2K="HOST-RESOURCES-MIB::hrSWRunPerfMem"
and then added after
MEMORY_USED_ID=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME $OID_TAGMEMORY | $CMD_GREP -i 'Physical Memory\|Real Memory' | $CMD_AWK '{ print $1}' | $CMD_AWK -F "." '{print $NF}'`
this test:
if [ -z "$MEMORY_USED_ID" ]; then
MEMORY_USED_ID="0"
fi
finally, in main block:
if [ $MEMORY_USED_ID != "0" ]; then
MEMORY_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL}.${MEMORY_USED_ID}`
SWAP_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL}.${SWAP_USED_ID}`
MEMORY_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_UNIT}.${MEMORY_USED_ID}`
SWAP_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_UNIT}.${SWAP_USED_ID}`
MEMORY_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_USED}.${MEMORY_USED_ID}`
SWAP_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_USED}.${SWAP_USED_ID}`
else
# Windows 2000
MEMORY_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL_W2K}.0`
SWAP_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_TOTAL}.${SWAP_USED_ID}`
MEMORY_UNIT=1024
SWAP_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_UNIT}.${SWAP_USED_ID}`
MEMORY_USED=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_USED_W2K} | cut -f 4 -d " " |paste -sd+|bc`
SWAP_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME ${OID_USED}.${SWAP_USED_ID}`
fi
Maybe isn't best way, but t works.
Regards
Cristiano