Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pysnmp.entity.rfc3413.oneliner import cmdgen
- # add your hosts here
- #targets = [ '127.0.0.1', '127.0.0.2' ]
- targets = ['127.0.0.1']*1000
- def cbFun(sendRequestHandle, errorIndication, errorStatus, errorIndex,
- varBinds, cbCtx):
- if errorIndication:
- print(errorIndication)
- return 1
- if errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1] or '?'
- )
- )
- return 1
- for oid, val in varBinds:
- if val is None:
- print(oid.prettyPrint())
- else:
- print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- cmdGen = cmdgen.AsynCommandGenerator()
- for transportTarget in targets:
- cmdGen.getCmd(
- cmdgen.CommunityData('public'),
- cmdgen.UdpTransportTarget((transportTarget, 161)),
- ( '1.3.6.1.2.1.1.1.0', ),
- # User-space callback function and its context
- (cbFun, None)
- )
- cmdGen.snmpEngine.transportDispatcher.runDispatcher()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement