Last active
September 20, 2016 16:04
-
-
Save jcurry/88a0fd0466eb44f62d65a805220b0e6c to your computer and use it in GitHub Desktop.
Use snmpGet to get size of storage allocation unit for storageSystem. Pass device parameters for snmp and filesystem snmpindex to get correct OID instance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Driven by | |
# /z/scripts/snmpGetHrStorageAllocationUnits.sh ${device/manageIp} ${device/zSnmpCommunity} ${device/zSnmpVer} ${here/snmpindex} | |
set -x | |
# Nagios return codes | |
STATE_OK=0 | |
STATE_WARNING=1 | |
STATE_CRITICAL=2 | |
STATE_UNKNOWN=3 | |
# | |
exitstatus=$STATE_OK | |
# Nagios format echos information and status followed by pipe | | |
# followed by <var name>=<value> tuples | |
# Note that Zenoss datapoints must match these var names exactly | |
# | |
#echo $1 $2 $3 $4 | |
# 1.3.6.1.2.1.25.2.3.1.4 is the OID for the host resources storage mib for blockSize - hrStorageAllocationUnits | |
# The snmpget needs to add the instance for each filesystem instance - this comes from the snmpindex attribute | |
# which is passed in the 4th parameter to the script | |
blockSize=$(/usr/bin/snmpget -$3 -c $2 -O qvU $1 1.3.6.1.2.1.25.2.3.1.4.$4 2>&1 | cut -f 1 -d " ") | |
# Response is: | |
# <number> Bytes to stdout | |
# No Such Instance currently exists at this OID to stdout | |
# Timeout: No Response from <ip> to stderr | |
# Use cut to get the first space-separated field | |
# | |
#Next line tests whether result is a number; if so then snmpget successful | |
if [ "$blockSize" -eq "$blockSize" ] 2>/dev/null | |
then | |
echo "Block size test - status OK | blockSize=$blockSize" | |
exit $exitstatus | |
elif [ "$blockSize" == "No" ] | |
then echo "Block size test failed -no such OID" | |
exitstatus=$STATE_CRITICAL | |
exit $exitstatus | |
elif | |
[ "$blockSize" == "Timeout:" ] | |
then echo "Block size test failed - no response" | |
exitstatus=$STATE_CRITICAL | |
exit $exitstatus | |
else | |
echo "Block size test failed -unknown error" | |
exitstatus=$STATE_UNKNOWN | |
exit $exitstatus | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment