我正在尝试使用Python查询Cisco路由设备上的SNMP变量,但遇到了困难。
我有一个有效的snmpwalk命令:
现在我正在尝试使用pysnmp在Python中完成同样的事情。
我尝试使用基于这里的示例http://pysnmp.sourceforge.net/examples/current/index.html,但遇到了SmiError。
基本上 - 我想在PySNMP中获得与此类似的NetSNMP等效项 (http://ben.akrin.com/?p=1234)。
有人知道在PySNMP中查询数字OID的简单方法吗?
干杯, 维克多
我有一个有效的snmpwalk命令:
$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
现在我正在尝试使用pysnmp在Python中完成同样的事情。
我尝试使用基于这里的示例http://pysnmp.sourceforge.net/examples/current/index.html,但遇到了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)
...: )
但我得到了以下内容:
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
基本上 - 我想在PySNMP中获得与此类似的NetSNMP等效项 (http://ben.akrin.com/?p=1234)。
有人知道在PySNMP中查询数字OID的简单方法吗?
干杯, 维克多