pythonsnmppysnmp

How to walk between to oids in pysnmp


I have the following code:

cmdGen = cmdgen.AsynCommandGenerator()
    cmdGen.asyncNextCmd(
        cmdgen.CommunityData('public', mpModel=0),
        cmdgen.UdpTransportTarget((ip, 161)),
        ((1,3,6,1,2,1,2,2,1,6,1),),#walks from this oid until end of mib table
        (cbFun_Mac_Address, (cmdgen.CommunityData('public', mpModel=0), cmdgen.UdpTransportTarget((ip, 161)))))
cmdGen.snmpEngine.transportDispatcher.runDispatcher()  

I want to walk between two oids(for example 1,3,6,1,2,1,2,2,1,6,1 - 1,3,6,1,2,1,2,2,1,6,9), but this code runs from (1,3,6,1,2,1,2,2,1,6,1) until the last oid found.
So how can i walk between to oids and not walk the whole mib table, using this syntax?


Solution

  • If your cbFun_Mac_Address() returns True, pysnmp will continue walking the same Agent. If your callback function returns False, pysnmp will stop walking right away. So your callback function should watch for the final OID to arrive and return False then. See this example.