#!/usr/bin/env python
#-*- coding: utf-8 -*-
from pysnmp.entity.rfc3413.oneliner import cmdgen
def cbFun(sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx):
print varBinds
def main():
ip = '127.0.0.1'
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.nextCmd(
cmdgen.CommunityData('mymypub')
cmdgen.UdpTransportTarget((ip, 161)),
'1.3.6.1.2.1.17.7.1.2.2.1.2')
#varBinds have about 200 elements
print varBinds
cmdGen = cmdgen.AsynCommandGenerator()
cmdGen.asyncNextCmd(
cmdgen.CommunityData('mymypub'),
cmdgen.UdpTransportTarget((ip, 161)),
((1,3,6,1,2,1,17,7,1,2,2,1,2),),
(cbFun, ip))
cmdGen.snmpEngine.transportDispatcher.runDispatcher()
#varBinds have 1 element
if __name__ == '__main__':
main()
我得到了 CommandGenerator 中的所有元素。但是我在 AsynCommandGenerator 中只有一个元素。我怎样才能得到所有这些?