У меня есть следующая функция:
def SnmpGetQuery(host,community,oid):
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.CommunityData(community),
cmdgen.UdpTransportTarget((host, 161)),
oid,
)
if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for name,val in varBinds:
return(str(val))
print(val)
Он работает нормально для одного OID, но когда я попытался передать больше OID, эта функция не работает,
Что у меня есть попробовал следующее, я создаю список с двумя OID,
oid_list = [oid1,oid2]
Затем здесь я изменяю oid, добавляя *
def SnmpGetQuery(host,community,oid):
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.CommunityData(community),
cmdgen.UdpTransportTarget((host, 161)),
*oid,
)
if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for name,val in varBinds:
return(str(val))
print(val)
И результат, который я получаю, если я что-то запускаю как
print (SnmpGetQuery (host, community, oid_list)) будет только первым OID в списке, который будет напечатан,
Есть мысли?
Спасибо:)