我有下面的代码,snmp没有得到它的工作很好,但当我试图拉一个设备(wlc)上的所有序列号使用接口编号循环't'时,它与print函数很好地工作,但当它保存到变量vaBinds[3][1]时,它只保存最后一个。如何在每次循环时保存所有变量值
不确定我的问题是否有意义,但请尽可能协助。先谢谢你
for t in range(1, 3):
t = str(t)
t.strip()
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
CommunityData(item, mpModel=0 or 1),
UdpTransportTarget((str(i), 161), timeout=0, retries=0),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0)), # 0
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)), # 1
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)), # 2
ObjectType(ObjectIdentity('ENTITY-MIB', 'entPhysicalSerialNum', t)), # 3
ObjectType(ObjectIdentity('ENTITY-MIB', 'entPhysicalModelName', t))), # 4
)
# print(varBinds[3][1])
if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(i),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) # error exceptions
else:
for varBind in varBinds:
B = varBinds[0]
目前没有回答
相关问题 更多 >
编程相关推荐