Date created: 10/05/15 09:28:16. Last modified: 09/19/17 12:03:30

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):

#!/bin/bash

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

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

echo -n "$subcount"