我正在尝试使用pySNMP获取批量OID。如果定义了一个带有OID的ObjectIdentity,则它可以工作,但对于多个,则抛出“超时前未收到SNMP响应”。 我正在使用此代码:
from pysnmp.hlapi import *
for errorIndication, errorStatus, \
errorIndex, varBinds in bulkCmd(
SnmpEngine(),
CommunityData('public'),
UdpTransportTarget(('host_ip', 161)),
ContextData(),
0, 50, # GETBULK specific: request up to 50 OIDs in a single response
# 10 index output
ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.8')),
ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.9')),
lookupMib=False, lexicographicMode=False):
if errorIndication:
print(errorIndication)
break
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex)-1][0] or '?'))
break
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
运行脚本的结果:如何获取多个OID的索引表?
No SNMP response received before timeout