我需要使用PySNMP的GetBulk实现来查询表oid的列表。我可以让它查询1个表OID,但无法让它从列表中读取表OID。我做错什么了?请帮忙。
from pysnmp.entity.rfc3413.oneliner import cmdgen
errorIndication, errorStatus, errorIndex, \
varBindTable = cmdgen.CommandGenerator().bulkCmd(
cmdgen.CommunityData('test-agent', 'public'),
cmdgen.UdpTransportTarget(('localhost', 161)),
0,
25,
(1,3,6,1,2,1,4,20) # ipAddrTable OID . This works fine.
# I also want to query .1.3.6.1.2.1.4.21 ipRouteTable in the same command
# Putting is as ( (1,3,6,1,2,1,4,20), (1,3,6,1,2,1,4,21) ) gives an error
)
if errorIndication:
print errorIndication
else:
if errorStatus:
print '%s at %s\n' % (
errorStatus.prettyPrint(),
errorIndex and varBindTable[-1][int(errorIndex)-1] or '?'
)
else:
for varBindTableRow in varBindTable:
for name, val in varBindTableRow:
print '%s = %s' % (name.prettyPrint(), val.prettyPrint())
试试这个…可能有用
我想这就是你想要的。。。
编辑
使用
我收到。。。
相关问题 更多 >
编程相关推荐