summaryrefslogtreecommitdiff
path: root/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/v3arch/asyncore/agent/ntforg/v2c-trap.py')
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/v2c-trap.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py
index 612074b7..4e3465b2 100644
--- a/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py
+++ b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py
@@ -55,33 +55,40 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# *** SNMP engine configuration is complete by this line ***
-# Create default SNMP context where contextEngineId == SnmpEngineId
+# Create Notification Originator App instance.
+ntfOrg = ntforg.NotificationOriginator()
+
+ # Create default SNMP context where contextEngineId == SnmpEngineId
snmpContext = context.SnmpContext(snmpEngine)
-# Create Notification Originator App instance.
-ntfOrg = ntforg.NotificationOriginator(snmpContext)
-
# Error/confirmation receiver
-def cbFun(sendRequestHandle, errorIndication, cbCtx):
+def cbFun(snmpEngine, sendRequestHandle, errorIndication,
+ errorStatus, errorIndex, varBinds, cbCtx):
print('Notification %s, status - %s' % (
sendRequestHandle, errorIndication and errorIndication or 'delivered'
)
)
# Build and submit notification message to dispatcher
-ntfOrg.sendNotification(
+sendRequestHandle = ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
'my-notification',
- # Trap OID (SNMPv2-MIB::coldStart)
+ # SNMP Context
+ snmpContext,
+ # contextName
+ '',
+ # notification name (SNMPv2-MIB::coldStart)
(1,3,6,1,6,3,1,1,5,1),
- # ( (oid, value), ... )
- ( ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
- ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ),
+ # instance Index
+ None,
+ # additional var-binds: ( (oid, value), ... )
+ [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')),
+ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ],
cbFun
)
-print('Notification is scheduled to be sent')
+print('Notification %s is scheduled to be sent' % sendRequestHandle)
# Run I/O dispatcher which would send pending message and process response
snmpEngine.transportDispatcher.runDispatcher()