snmpEngine = engine.SnmpEngine() try: # Parse c/l into AST ast = Parser().parse(Scanner().tokenize(' '.join(sys.argv[1:]))) ctx = {} # Apply configuration to SNMP entity main.generator((snmpEngine, ctx), ast) msgmod.generator((snmpEngine, ctx), ast) secmod.generator((snmpEngine, ctx), ast) mibview.generator((snmpEngine, ctx), ast) target.generator((snmpEngine, ctx), ast) pdu.writePduGenerator((snmpEngine, ctx), ast) cmdgen.SetCommandGenerator().sendVarBinds(snmpEngine, ctx['addrName'], ctx.get('contextEngineId'), ctx.get('contextName', ''), ctx['varBinds'], cbFun, ctx) snmpEngine.transportDispatcher.runDispatcher() except KeyboardInterrupt: sys.stderr.write('Shutting down...\n') except error.PySnmpError: sys.stderr.write('Error: %s\n%s' % (sys.exc_info()[1], getUsage())) sys.exit(-1)
try: # Parse c/l into AST ast = Parser().parse( Scanner().tokenize(' '.join(sys.argv[1:])) ) ctx = {} # Apply configuration to SNMP entity main.generator((snmpEngine, ctx), ast) msgmod.generator((snmpEngine, ctx), ast) secmod.generator((snmpEngine, ctx), ast) mibview.generator((snmpEngine, ctx), ast) target.generatorTrap((snmpEngine, ctx), ast) pdu.writePduGenerator((snmpEngine, ctx), ast) generator((snmpEngine, ctx), ast) v2c.apiPDU.setVarBinds( ctx['pdu'], v2c.apiPDU.getVarBinds(ctx['pdu']) + ctx['varBinds'] ) ntforg.NotificationOriginator().sendPdu( snmpEngine, ctx['addrName'], ctx.get('contextEngineId'), ctx.get('contextName', ''), ctx['pdu'], cbFun, ctx )