pysnmp icon indicating copy to clipboard operation
pysnmp copied to clipboard

How to stop walking the MIB once the initial prefix goes out of scope when using asyncore

Open Tualua opened this issue 6 years ago • 2 comments

Hello! How to stop walking the MIB once the initial prefix goes out of scope with asyncore?

In synchronous mode I can use lexicographicMode=False, but if I try to use it in this example http://snmplabs.com/pysnmp/examples/hlapi/asyncore/manager/cmdgen/walking-operations.html it does not have any effect

I want to get interface names from Cisco switch, OID is 1.3.6.1.2.1.31.1.1.1.1 I can get them with this example, but it continues walking after getting this OID

SNMPv2-SMI::mib-2.31.1.1.1.1.10048 = Fa1/0/48
SNMPv2-SMI::mib-2.31.1.1.1.1.10101 = Gi1/0/1
SNMPv2-SMI::mib-2.31.1.1.1.1.10102 = Gi1/0/2
SNMPv2-SMI::mib-2.31.1.1.1.1.10103 = Gi1/0/3
SNMPv2-SMI::mib-2.31.1.1.1.1.10104 = Gi1/0/4
SNMPv2-SMI::mib-2.31.1.1.1.1.14501 = Nu0
-------<need to stop here>--------
SNMPv2-SMI::mib-2.31.1.1.1.2.10001 = 114
SNMPv2-SMI::mib-2.31.1.1.1.2.10002 = 266
SNMPv2-SMI::mib-2.31.1.1.1.2.10003 = 40
SNMPv2-SMI::mib-2.31.1.1.1.2.10004 = 1046

Thanks!

Tualua avatar Feb 21 '20 06:02 Tualua

+1 on this, what's the cleanest way to accomplish this while using cmdgen or async?

lamoni avatar Mar 17 '21 15:03 lamoni

Related to #350.

If you want to stop at a certain place, you need to modify cbFun in the sample code,

https://github.com/etingof/pysnmp/blob/v4.4.12/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py

Instead of returning True all the times, you can let it stop anywhere you like.

lextm avatar Jan 20 '23 05:01 lextm