我重新尝试从某个网络交换机中获取一些孩子,为此我使用了一个名为 pysnmp 的 purepyton 库。它的安装没有问题。
使用了一个有效的示例代码。
from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
datos = []
ip = 'theipaddress'
comunidad_snmp = 'thecomunityv2c'
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.CommunityData(comunidad_snmp),
cmdgen.UdpTransportTarget((ip, 161)),
'.1.3.6.1.2.1.1.1.0', # sysDescr.0
lookupNames=True, lookupValues=True
)
if errorIndication:
print(errorIndication)
elif errorStatus:
print(errorStatus)
else:
for name, val in varBinds:
datos.append({'nombre': name.prettyPrint(), 'valor': val.prettyPrint()})
print datos
我们的问题是,如果我在任何视图中复制此代码(原样),结果总是
"No SNMP response received before timeout"
我们需要添加一些东西才能按预期工作吗?
环境是美分6