I looked for any SNMP scanner tool for Linux that can SNMP query an IP range for multiple OIDs and return results (if found), but didn't find anything.
I have SNMP installed on Ubuntu, is it possible with snmpget command query the network range for multiple OIDs and retrieve MIB values? Is it possible do this from terminal as single command?
For example, snmpget network range 10.40.70.1/24 for 4 OIDs (OID1, OID2, OID3, OID4).
snmpwalk
, otherwisesnmpbulkget
. But afaik network ranges are not supported by snmp tools, as they only allow the definition of one agent.for (( i=254; $i; i=$i-1 )) do host=10.40.70.$i; if (ping -q -c 1 $host >/dev/null); then snmpget -v2c -c public $host OID1 OID2 OID3 OID4; fi; done
. But that might bring you trouble with your network administrator...man snmpget
says so... maybe remove the>/dev/null
to see what's going on. Or instead of testing withping
you could immediately callsnmpget
:for (( i=254; $i; i=$i-1 )) do host=10.40.70.$i; snmpget -v 2c -c public $host OID1 OID2 OID3 OID4; done
. And of course change the options of snmpget to match your needs (-v 2c and -c public is just an example)-t 0.5 -r 1
to thesnmpget
options; this will return faster withtimeout
(but you might not catch all hosts this way). And be aware that the line suggested implies that all hosts have same snmp version and community. To keep a script from exiting at the end you may useread
:read -p 'press enter to continue...' answer