I'am new in this thing,
When I run the following command:
snmpwalk -v2c -c public localhost .1.3.6.1.4.1.3375.2.2.5.6.2.1.6
in my F5 LTM I get all my nodes, pools and state like this:
F5-BIGIP-LOCAL-MIB::ltmPoolMbrStatusEnabledState."/Common/pool-cnv-proc-financeiro-processamento-was-9169"."/Common/HAPP102".9169 = INTEGER: enabled(1)
But when I use the same OID by pysnmp I get this:
[ObjectType(ObjectIdentity(<ObjectName value object at 0x6373150 tagSet <TagSet object at 0x4ab5190 tags 0:0:6> payload [1.3.6.1.4.1.3375...80.49.48.52.9144]>), <Integer value object at 0x6373050 subtypeSpec <ConstraintsIntersection object at 0x4ab5c90 consts <ValueRangeConstraint object at 0x4a17c90 consts -2147483648, 2147483647>> tagSet <TagSet object at 0x4aabad0 tags 0:0:2> payload [1]>)]
My question:
Is there a way to parse this pysnmp response or am I doing something wrong?
Here is the python code:
from pysnmp.hlapi import *
def walk(host, oid):
for (errorIndication, errorStatus, errorIndex, varBinds) in nextCmd(SnmpEngine(),
CommunityData('public'),
UdpTransportTarget((host, 161)),
ContextData(),
ObjectType(ObjectIdentity(oid)),
lexicographicMode=False):
if errorIndication:
break
elif errorStatus:
break
else:
for varBind in varBinds:
print(varBind)
walk('10.10.100.89', '1.3.6.1.4.1.3375.2.2.5.6.2.1.6')
You just need to .prettyPrint()
the pysnmp objects you get in response:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
Like shown in the examples.
EDIT:
If you want the response variable-bindings to be resolved against a MIB, you need to load that MIB (perhaps, F5-BIGIP-LOCAL-MIB
) into pysnmp like this:
...
ContextData(),
ObjectType(ObjectIdentity(oid)).loadMibs('F5-BIGIP-LOCAL-MIB'),
...
Alternatively, if you specify MIB symbols in request (as opposed to specifying OIDs), pysnmp will load up the named MIB automatically.
...
ContextData(),
ObjectType(ObjectIdentity('F5-BIGIP-LOCAL-MIB', 'ltmPoolMbrStatusEnabledState')),
...