I am trying to query an SNMP variable on a Cisco routing device in Python and am struggling.
I have a snmpwalk command that works fine:
$snmpwalk -v2c -c <our_community_string> <device_ip_address> 1.3.6.1.4.1.9.9.42.1.2.10.1.1.950 SNMPv2-SMI::enterprises.9.9.42.1.2.10.1.1.950 = Gauge32: 68
Now I am trying to do the same in Python using pysnmp.
I tried using something based on examples here - http://pysnmp.sourceforge.net/examples/current/index.html - but got a SmiError:
In [1]: from pysnmp.entity.rfc3413.oneliner import cmdgen In [2]: cmdGen = cmdgen.CommandGenerator() In [3]: errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd( ...: cmdgen.CommunityData('0pe3aro'), ...: cmdgen.UdpTransportTarget(('10.65.113.28', 161)), ...: cmdgen.MibVariable('1.3.6.1.4.1.9.9.42.1.2.10.1.1.950', 0) ...: )
But I get the following:
SmiError: MIB file "1.3.6.1.4.1.9.9.42.1.2.10.1.1.950.py[co]" not found in search path
Basically - I wanted it to be in NetSNMP, but in PySNMP ( http://ben.akrin.com/?p=1234 ).
Does anyone know an easy way to request a numeric OID in PySNMP?
Cheers, Victor
source share