You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Was trying to retrieve all variables per MIB and realized that running nextCmd with the option lexicographicMode unset (defaults to True according to the docs) yields beyond the scope of the MIB. Tried to explicitly set it to False and now it does not go beyond the scope of the MIB.
from pysnmp import hlapi as snmp
iterator = snmp.nextCmd(
snmp.SnmpEngine(),
snmp.CommunityData('public'),
snmp.UdpTransportTarget(('192.168.1.11', 161)),
snmp.ContextData(),
snmp.ObjectType(snmp.ObjectIdentity('IF-MIB')),
lexicographicMode=False, # After setting this to False, it now seems return only the IF-MIB OIDs.
)
for errorIndication, errorStatus, errorIndex, varBinds in iterator:
if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
print('=' * 80)
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
Or was I missing something?
I'm running on:
python:3.6 (docker)
pysnmp==4.3.5
pysmi==0.1.0
pysnmp-mibs==0.1.6
The text was updated successfully, but these errors were encountered:
I think the documentation was confusing in regards to lexicographicMode option. I've just reworded it what would hopefully explains the behavior you observe.
In short -- "lexicographicMode = True" walks the MIB till the very end, otherwise walk is capped by the initial OIDs (serve as prefixes). You can change those prefixes at any time by feeding the new ones back into running generator (via its .send() method).
Excellent work on the project!
Was trying to retrieve all variables per MIB and realized that running
nextCmd
with the optionlexicographicMode
unset (defaults toTrue
according to the docs) yields beyond the scope of the MIB. Tried to explicitly set it toFalse
and now it does not go beyond the scope of the MIB.Or was I missing something?
I'm running on:
python:3.6 (docker)
pysnmp==4.3.5
pysmi==0.1.0
pysnmp-mibs==0.1.6
The text was updated successfully, but these errors were encountered: