0

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?

yuval
  • 2,848
  • 4
  • 31
  • 51

2 Answers2

1

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.

Ilya Etingof
  • 5,440
  • 1
  • 17
  • 21
0

On the Example mentioned below:

http://pysnmp.sourceforge.net/examples/current/v3arch/oneliner/manager/cmdgen/getnext-async-multiple-transports-and-protocols.html

if you change line:

 if val is not None and varBindHead[idx] <= name:

to:

 if val is not None and varBindHead[idx] == name[0:len(varBindHead[idx])]:

You match exactly the branch you want to walk through.

Ashkan S
  • 10,464
  • 6
  • 51
  • 80
Roger Sacchelli
  • 131
  • 1
  • 4