Date created: Monday, October 5, 2015 9:28:16 AM. Last modified: Tuesday, April 2, 2019 9:50:02 PM

Feed from BASH, snmpget v2c & v3

This example script uses snmpget to poll a specific SNMP OID using either SNMP v2c or SNMP v3 (if the NMS can not support specifying SNMP OIDs):


# SNMP v2c
#subcount=`snmpget -v 2c -c S3cr3tStr1ng | awk {'print $NF'}`

# SNMP v3
##subcount=`snmpget -v 3 -n "" -u snmpuser -a MD5 -A "password" -x AES -X "authphrase" -l authPriv | awk {'print $NF'}`

# Specific source IP
# subcount=`snmpwalk --clientaddr= ...`
echo -n "$subcount"