Superfast parallel snmpbulkwalk
Fastsnmpy is a module that leverages python-extensions that come with net-snmp and provide highly parallelized faster-methods to walk oid-trees on devices.
In addition, it provides a method to bulkwalk mib-trees..
BulkWalk methods are missing from native python-bindings for net-snmp. By creating a wrapper around the GetBulk method instead, and maintaining state while traversing the oid-tree, fastsnmpy provides a clever solution to bulkwalk oids much faster
FastSNMPy provides the following:
- snmpwalk(): Native python-bindings distributed with net-snmp, combined with fastsnmpy’s ability to parallelize snmpwalk operations.
- snmpbulkwalk(): Ability to snmpbulkwalk devices, which makes it several magnitudes faster than net-snmp’s implementation of snmpwalk.
- By leveraging the getbulk method, this module provides a quick snmpbulkwalk utility.
- PROCESS-POOLS: By passing in a ‘workers=n’ attribute to the above methods, fastsnmpy can instantiate a process-pool to parallelize the snmpwalk and snmpbulkwalk methods, resulting in several devices being walked at the same time, effectively using all cores on a multicore machine.
- One-Line, and Two-Line scripts that enable you to discover/walk all devices in a whole datacenter
Quick example – Running in interactive mode
>> import netsnmp
>> from fastsnmpy import SnmpSession
>> hosts =['c7200-2','c7200-1','c2600-1','c2600-2']
>> oids = ['ifDescr', 'ifIndex', 'ifName', 'ifDescr']
>> newsession = SnmpSession ( targets = hosts, oidlist = oids, community='oznet' )
>> results = newsession.snmpbulkwalk(workers=15)
Note: To use the module in scripts, please see the example.py included with the package.
(1) Walking 30 nodes for ifDescr using snmpwalk():
(2) Walking 30 nodes for ifDescr using snmpbulkwalk():
(3) Walking 30 nodes for ifDescr using snmpwalk(workers=10):
(4) Walking 30 nodes for ifDescr using snmpbulkwalk(workers=10):
As you can see, fastsnmpy’s bulkwalk mode is almost 20 times faster than using python’s native snmp bindings for walking
Get from Git
Or fork from the git-repo GitHub-FastSNMPy