Open edouard-lopez opened 8 years ago
I check to see if one of the oid
was problematic and it '.1.3.6.1.2.1.43.10.2.1.4.1.1'
is the culprit
oids = [
'.1.3.6.1.2.1.43.10.2.1.4.1.1' # SNMPv2-SMI::mib-2.43.10.2.1.4.1.1 page count
'.1.3.6.1.2.1.25.3.2.1.3.1', # HOST-RESOURCES-MIB::hrDeviceDescr.1
]
oids = [
'.1.3.6.1.2.1.25.3.2.1.3.1', # HOST-RESOURCES-MIB::hrDeviceDescr.1
'.1.3.6.1.2.1.43.10.2.1.4.1.1' # SNMPv2-SMI::mib-2.43.10.2.1.4.1.1 page count
]
I tried again with the full list and putting the problematic oid
as the last item of the list and it work…
oids = [
'.1.3.6.1.2.1.25.3.2.1.3.1', # HOST-RESOURCES-MIB::hrDeviceDescr.1
'.1.3.6.1.2.1.1.4.0', # SNMPv2-MIB::sysContact.0
'.1.3.6.1.2.1.1.1.0', # SNMPv2-MIB::sysDescr.0
'.1.3.6.1.2.1.1.5.0', # SNMPv2-MIB::sysName.0
'.1.3.6.1.2.1.1.3.0', # DISMAN-EVENT-MIB::sysUpTimeInstance
'.1.3.6.1.2.1.43.10.2.1.4.1.1' # SNMPv2-SMI::mib-2.43.10.2.1.4.1.1 page count
]
Why is the oid
s order relevant to session.get(*oids)
? cc @vincentbernat
Error reporting with SNMPv1 is misleading. You could first try with SNMPv2 instead.
Your snmpget is not equivalent. Try this instead:
declare -a oids=(
'.1.3.6.1.2.1.25.3.2.1.3.1' # HOST-RESOURCES-MIB::hrDeviceDescr.1
'.1.3.6.1.2.1.43.10.2.1.4.1.1' # SNMPv2-SMI::mib-2.43.10.2.1.4.1.1 page count
'.1.3.6.1.2.1.1.4.0' # SNMPv2-MIB::sysContact.0
'.1.3.6.1.2.1.1.1.0' # SNMPv2-MIB::sysDescr.0
'.1.3.6.1.2.1.1.5.0' # SNMPv2-MIB::sysName.0
'.1.3.6.1.2.1.1.3.0' # DISMAN-EVENT-MIB::sysUpTimeInstance
)
snmpget -v 1 -t .3 -r 2 -c public 192.168.2.250 -m +SNMPv2-MIB ${oids[@]}
I suspect you'll also get the same kind of error. Order is unimportant but there can be a bug in the agent side (server side).
Bash is working fine, it's the python code that's not working as expected.
I'm having an exception raised, but I don't get why
Code
Error
Doing it in bash works
Reaching the equipment using
bash
andsnmpget
command works fine:output:
Question
What's the matter here?