[pysnmp-users] Help understanding walking MIB
Brought to you by:
elie
From: Denis F. <pyt...@le...> - 2015-10-04 12:46:09
|
Hi, I am using pysnmp 4.3.0 with Linux/Debian 8. I have the following code (basically getbulk-limit-number-of-packets.py example) : ------8<------ from pysnmp.hlapi import * for errorIndication, \ errorStatus, errorIndex, \ varBinds in bulkCmd(SnmpEngine(), CommunityData('public'), UdpTransportTarget(('snmp', 161)), ContextData(), 0, 50, ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1')), maxCalls=10): if errorIndication: print(errorIndication) break elif errorStatus: print('%s at %s' % ( errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex)-1][0] or '?' ) ) break else: for varBind in varBinds: print(' = '.join([ x.prettyPrint() for x in varBind ])) ------8<------ I'm expecting it to return only what lies under 1.3.6.1.2.1.2.2.1 but I get : ------8<------ [...] SNMPv2-SMI::mib-2."2.2.1.22.3" = 0.0 SNMPv2-SMI::mib-2."2.2.1.22.4" = 0.0 SNMPv2-SMI::mib-2."2.2.1.22.5" = 0.0 SNMPv2-SMI::mib-2."2.2.1.22.6" = 0.0 SNMPv2-SMI::mib-2."2.2.1.22.7" = 0.0 SNMPv2-SMI::mib-2."2.2.1.22.8" = 0.0 SNMPv2-SMI::mib-2."2.2.1.22.9" = 0.0 SNMPv2-SMI::mib-2."4.1.0" = 1 SNMPv2-SMI::mib-2."4.2.0" = 64 SNMPv2-SMI::mib-2."4.3.0" = 8165257 SNMPv2-SMI::mib-2."4.4.0" = 0 SNMPv2-SMI::mib-2."4.5.0" = 1176834 SNMPv2-SMI::mib-2."4.6.0" = 6851141 SNMPv2-SMI::mib-2."4.7.0" = 39 [...] ------8<------ Why is it returning results from 1.3.6.1.2.1.4 ? Using net-snmp snmpwalk returns only the MIB I asked for. On a similar side, if I have two MIBs to be walked, like in the following code : ------8<------ from pysnmp.hlapi import * for errorIndication, \ errorStatus, errorIndex, \ varBinds in bulkCmd(SnmpEngine(), CommunityData('public'), UdpTransportTarget(('snmp', 161)), ContextData(), 0, 50, ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1')), ObjectType(ObjectIdentity('1.3.6.1.2.1.31.1.1.1')), maxCalls=10): if errorIndication: print(errorIndication) break elif errorStatus: print('%s at %s' % ( errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex)-1][0] or '?' ) ) break else: for varBind in varBinds: print(' = '.join([ x.prettyPrint() for x in varBind ])) ------8<------ I get : ------8<------ SNMPv2-SMI::mib-2."2.2.1.1.1" = 1 SNMPv2-SMI::mib-2."31.1.1.1.1.1" = em0 SNMPv2-SMI::mib-2."31.1.1.1.1.2" = em1 SNMPv2-SMI::mib-2."31.1.1.1.1.3" = em2 [...] SNMPv2-SMI::mib-2."31.1.6.0" = 1406953 SNMPv2-SMI::enterprises."2021.13.15.1.1.1.1" = 1 SNMPv2-SMI::enterprises."2021.13.15.1.1.2.1" = sd0 SNMPv2-SMI::enterprises."2021.13.15.1.1.3.1" = 1938226688 ------8<------ Only the first OID of the first MIB, what looks like the full second MIB and part of a third one... I was expecting the full first and second MIBs. What do I get wrong about this behaviour ? Thank you in advance, Denis |