diff options
author | elie <elie> | 2012-11-28 21:54:59 +0000 |
---|---|---|
committer | elie <elie> | 2012-11-28 21:54:59 +0000 |
commit | f17686444816f6b2aa8ec8ede5b662ff015058b5 (patch) | |
tree | d121f00935f34613b54b283f2210e53f9b663ea6 | |
parent | 5e0b4d302cfcb2c9663c385790c9a2b32957bfe5 (diff) | |
download | pysnmp-f17686444816f6b2aa8ec8ede5b662ff015058b5.tar.gz |
SNMPv3 native Notification Originator examples extended to cover
many use cases
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg.py | 181 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/inform-multiple-protocols.py | 108 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/inform-v2c.py | 87 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/inform-v3.py | 85 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py | 79 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/trap-v1.py | 97 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py | 95 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/trap-v2c-multiple-targets.py | 94 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py | 94 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/trap-v2c-with-objects.py | 124 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/trap-v2c.py | 87 | ||||
-rw-r--r-- | examples/v3arch/agent/ntforg/trap-v3.py | 82 |
13 files changed, 1034 insertions, 181 deletions
@@ -1,6 +1,8 @@ Revision 4.2.4 -------------- +- SNMPv3 native Notification Originator examples extended to cover + many use cases. - The missing functionality of NOTIFICATION-TYPE objects being looked up at local Management Instrumentation and attached to TRAP/IMFORM message by Notification Originator is now fully implemented. diff --git a/examples/v3arch/agent/ntforg.py b/examples/v3arch/agent/ntforg.py deleted file mode 100644 index 4b2e74b..0000000 --- a/examples/v3arch/agent/ntforg.py +++ /dev/null @@ -1,181 +0,0 @@ -# Notification originator -from pysnmp.entity import engine, config -from pysnmp.carrier.asynsock.dgram import udp, udp6, unix -from pysnmp.entity.rfc3413 import ntforg, context -from pysnmp.proto.api import v2c -#from pysnmp import debug - -## Optional debugging ('all' enables full debugging) -#debug.setLogger(debug.Debug('io', 'dsp', 'msgproc', 'secmod', 'app')) - -# Create SNMP engine instance with specific local snmpEngineId value. -# When sending SNMPv3 TRAPs, this value should also be configured -# to TRAP receiver's users table. -snmpEngine = engine.SnmpEngine( - v2c.OctetString(hexValue='8000000001020304') -) - -# -# SNMPv1/2c setup (if you use SNMPv1 or v2c) -# - -## SecurityName <-> CommunityName mapping -config.addV1System(snmpEngine, 'my-area', 'public') - -## Specify security settings per SecurityName (SNMPv1 - 0, SNMPv2c - 1) -#config.addTargetParams(snmpEngine, 'my-creds-1', 'my-area', 'noAuthNoPriv', 0) -config.addTargetParams(snmpEngine, 'my-creds-1', 'my-area', 'noAuthNoPriv', 1) - -# -# SNMPv3/USM setup (choose any one if you use SNMPv3/USM) -# - -# user: usr-md5-des, auth: MD5, priv DES -config.addV3User( - snmpEngine, 'usr-md5-des', - config.usmHMACMD5AuthProtocol, 'authkey1', - config.usmDESPrivProtocol, 'privkey1' -) -config.addTargetParams(snmpEngine, 'my-creds-3', 'usr-md5-des', 'authPriv') - -## user: usr-none-none, auth: NONE, priv NONE -#config.addV3User( -# snmpEngine, 'usr-none-none' -#) -#config.addTargetParams(snmpEngine, 'my-creds', 'usr-none-none', 'noAuthNoPriv') - -## user: usr-md5-none, auth: MD5, priv NONE -#config.addV3User( -# snmpEngine, 'usr-md5-none', -# config.usmHMACMD5AuthProtocol, 'authkey1' -#) -#config.addTargetParams(snmpEngine, 'my-creds', 'usr-md5-none', 'authNoPriv') - -## user: usr-sha-aes128, auth: SHA, priv AES -#config.addV3User( -# snmpEngine, 'usr-sha-aes128', -# config.usmHMACSHAAuthProtocol, 'authkey1', -# config.usmAesCfb128Protocol, 'privkey1' -#) -#config.addTargetParams(snmpEngine, 'my-creds', 'usr-sha-aes128', 'authPriv') - -## user: usr-md5-aes256, auth: MD5, priv AES256 -#config.addV3User( -# snmpEngine, 'usr-md5-aes256', -# config.usmHMACMD5AuthProtocol, 'authkey1', -# config.usmAesCfb256Protocol, 'privkey1' -#) -#config.addTargetParams(snmpEngine, 'my-creds', 'usr-md5-aes256', 'authPriv') - -## user: usr-md5-aes192, auth: MD5, priv AES192 -#config.addV3User( -# snmpEngine, 'usr-md5-aes192', -# config.usmHMACMD5AuthProtocol, 'authkey1', -# config.usmAesCfb192Protocol, 'privkey1' -#) -#config.addTargetParams(snmpEngine, 'my-creds', 'usr-md5-aes192', 'authPriv') - -## user: usr-md5-3des, auth: MD5, priv 3DES -#config.addV3User( -# snmpEngine, 'usr-md5-3des', -# config.usmHMACMD5AuthProtocol, 'authkey1', -# config.usm3DESEDEPrivProtocol, 'privkey1' -#) -#config.addTargetParams(snmpEngine, 'my-creds', 'usr-md5-3des', 'authPriv') - -# -# Setup transport endpoint and bind it with security settings yielding -# a target name. Since Notifications could be sent to multiple Managers -# at once, more than one target entry may be configured (and tagged). -# - -# UDP/IPv4 -config.addSocketTransport( - snmpEngine, - udp.domainName, - udp.UdpSocketTransport().openClientMode() -) -config.addTargetAddr( - snmpEngine, 'my-nms-1', - udp.domainName, ('127.0.0.1', 162), - 'my-creds-1', - tagList='all-my-managers' -) - -## UDP/IPv6 -config.addSocketTransport( - snmpEngine, - udp6.domainName, - udp6.Udp6SocketTransport().openClientMode() -) -config.addTargetAddr( - snmpEngine, 'my-nms-2', - udp6.domainName, ('::1', 162), - 'my-creds-3', - tagList='all-my-managers' -) - -## Local domain socket -#config.addSocketTransport( -# snmpEngine, -# unix.domainName, -# unix.UnixSocketTransport().openClientMode() -#) -#config.addTargetAddr( -# snmpEngine, 'my-nms', -# unix.domainName, '/tmp/snmp-manager', -# 'my-creds', -# tagList='all-my-managers' -#) - -# -# Specify what kind of notification should be sent (TRAP or INFORM) -# to what targets (chosen by tag) and with what credentials. -# -config.addNotificationTarget( -# snmpEngine, 'my-notification', 'my-creds', 'all-my-managers', 'trap' - snmpEngine, 'my-notification', 'my-creds', 'all-my-managers', 'inform' -) - -# -# Notifications carry potentially confidential information from -# the Agent. Therefore access control is to be setup allowing -# NotificationOriginator access to certain portions of Agent MIB. -# -config.addContext(snmpEngine, '') -# SNMPv1 -config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) -# SNMPv2c -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) -# SNMPv3 -config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (), (), (1,3,6)) -config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authPriv', (), (), (1,3,6)) -config.addVacmUser(snmpEngine, 3, 'usr-none-none', 'authPriv', (), (), (1,3,6)) -config.addVacmUser(snmpEngine, 3, 'usr-md5-aes192', 'authPriv', (), (),(1,3,6)) -config.addVacmUser(snmpEngine, 3, 'usr-md5-aes256', 'authPriv', (), (),(1,3,6)) -config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (), (),(1,3,6)) -config.addVacmUser(snmpEngine, 3, 'usr-md5-3des', 'authPriv', (), (),(1,3,6)) - -# SNMP context -snmpContext = context.SnmpContext(snmpEngine) - -# # Error/confirmation reciever -def cbFun(sendRequestHandle, errorIndication, cbCtx): - print('Notification %s, status - %s' % (sendRequestHandle, errorIndication and errorIndication or 'delivered')) - -sendRequestHandle = ntforg.NotificationOriginator(snmpContext).sendNotification( - snmpEngine, - # Notification targets - 'my-notification', - # Trap OID (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')) ), - cbFun -) - -print('Notification %s scheduled to be sent' % sendRequestHandle) - -# Run I/O dispatcher which would send pending message and process response -snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/inform-multiple-protocols.py b/examples/v3arch/agent/ntforg/inform-multiple-protocols.py new file mode 100644 index 0000000..42e7470 --- /dev/null +++ b/examples/v3arch/agent/ntforg/inform-multiple-protocols.py @@ -0,0 +1,108 @@ +# +# Notification Originator +# +# Send SNMP INFORM notifications to multiple Managers using the +# following options: +# +# * SNMPv2c +# * with community name 'public' +# * AND +# * SNMPv3 +# * with user 'usr-md5-none', auth: MD5, priv NONE +# * over IPv4/UDP +# * send INFORM notification +# * to multiple Managers at 127.0.0.1:162, 127.0.0.2:162 +# * with TRAP ID 'coldStart' specified as an OID +# * include managed objects information: +# 1.3.6.1.2.1.1.1.0 = 'Example Notificator' +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# SNMPv2c: + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + +# Specify security settings per SecurityName (SNMPv2c -> 1) +config.addTargetParams(snmpEngine, 'my-creds-1', 'my-area', 'noAuthNoPriv', 1) + +# SNMPv3: + +config.addV3User( + snmpEngine, 'usr-md5-none', + config.usmHMACMD5AuthProtocol, 'authkey1' +) +config.addTargetParams(snmpEngine, 'my-creds-2', 'usr-md5-none', 'authNoPriv') + +# Setup transport endpoint and bind it with security settings yielding +# a target name +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +# First target +config.addTargetAddr( + snmpEngine, 'my-nms-1', + udp.domainName, ('127.0.0.1', 162), + 'my-creds-1', + tagList='all-my-managers' +) +# Second target +config.addTargetAddr( + snmpEngine, 'my-nms-2', + udp.domainName, ('127.0.0.1', 162), + 'my-creds-2', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'inform' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (2&3), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6)) + +# *** SNMP engine configuration is complete by this line *** + +# Create default SNMP context where contextEngineId == SnmpEngineId +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Error/confirmation reciever +def cbFun(sendRequestHandle, errorIndication, cbCtx): + print('Notification %s, status - %s' % ( + sendRequestHandle, errorIndication and errorIndication or 'delivered' + ) + ) + +# Build and submit notification message to dispatcher +ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # Trap OID (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')), ), + cbFun +) + +print('Notifications are scheduled to be sent') + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/inform-v2c.py b/examples/v3arch/agent/ntforg/inform-v2c.py new file mode 100644 index 0000000..a5a9b21 --- /dev/null +++ b/examples/v3arch/agent/ntforg/inform-v2c.py @@ -0,0 +1,87 @@ +# +# Notification Originator +# +# Send SNMP INFORM notification using the following options: +# +# * SNMPv2c +# * with community name 'public' +# * over IPv4/UDP +# * send INFORM notification +# * to a Manager at 127.0.0.1:162 +# * with TRAP ID 'coldStart' specified as an OID +# * include managed objects information: +# 1.3.6.1.2.1.1.1.0 = 'Example Notificator' +# 1.3.6.1.2.1.1.5.0 = 'Notificator Example' +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + +# Specify security settings per SecurityName (SNMPv2c -> 1) +config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1) + +# Setup transport endpoint and bind it with security settings yielding +# a target name +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +config.addTargetAddr( + snmpEngine, 'my-nms', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'inform' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +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 +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Error/confirmation reciever +def cbFun(sendRequestHandle, errorIndication, cbCtx): + print('Notification %s, status - %s' % ( + sendRequestHandle, errorIndication and errorIndication or 'delivered' + ) + ) + +# Build and submit notification message to dispatcher +sendRequestHandle = ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # Trap OID (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')) ), + cbFun +) + +print('Notification %s scheduled to be sent' % sendRequestHandle) + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/inform-v3.py b/examples/v3arch/agent/ntforg/inform-v3.py new file mode 100644 index 0000000..ce7316e --- /dev/null +++ b/examples/v3arch/agent/ntforg/inform-v3.py @@ -0,0 +1,85 @@ +# +# Notification Originator +# +# Send SNMP INFORM notification using the following options: +# +# * SNMPv3 +# * with user 'usr-md5-none', auth: MD5, priv NONE +# * over IPv4/UDP +# * to a Manager at 127.0.0.1:162 +# * send INFORM notification +# * with TRAP ID 'warmStart' specified as an OID +# * include managed object information 1.3.6.1.2.1.1.5.0 = 'system name' +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# Add USM user +config.addV3User( + snmpEngine, 'usr-md5-none', + config.usmHMACMD5AuthProtocol, 'authkey1' +) +config.addTargetParams(snmpEngine, 'my-creds', 'usr-md5-none', 'authNoPriv') + +# Setup transport endpoint and bind it with security settings yielding +# a target name +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +config.addTargetAddr( + snmpEngine, 'my-nms', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'inform' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (3), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6)) + +# *** SNMP engine configuration is complete by this line *** + +# Create default SNMP context where contextEngineId == SnmpEngineId +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Error/confirmation reciever +def cbFun(sendRequestHandle, errorIndication, cbCtx): + print('Notification %s, status - %s' % ( + sendRequestHandle, errorIndication and errorIndication or 'delivered' + ) + ) + +# Build and submit notification message to dispatcher +sendRequestHandle = ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # Trap OID (SNMPv2-MIB::coldStart) + (1,3,6,1,6,3,1,1,5,1), + # ( (oid, value), ... ) + ( ((1,3,6,1,2,1,1,5,0), v2c.OctetString('system name')), ), + cbFun +) + +print('Notification %s scheduled to be sent' % sendRequestHandle) + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py b/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py new file mode 100644 index 0000000..81dc1b7 --- /dev/null +++ b/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py @@ -0,0 +1,79 @@ +# +# Notification Originator +# +# Send SNMP notification using the following options: +# +# * SNMPv1 +# * with community name 'public' +# * over IPv4/UDP +# * to a Manager at 127.0.0.1 UDP port 162 +# * from local address 127.0.0.1, UDP port 1024 +# * send TRAP notification +# * with TRAP ID 'coldStart' specified as an OID +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c +from pysnmp import debug + +# Optional debugging ('all' enables full debugging) +debug.setLogger(debug.Debug('app', 'dsp')) + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + +# Specify security settings per SecurityName (SNMPv1 -> 0) +config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 0) + +# Setup transport endpoint and bind it with security settings yielding +# a target name. Pay attention to the openClientMode() parameter -- it's +# used to originate packets from particular local IP:port +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode(iface=('127.0.0.1', 1024)) +) +config.addTargetAddr( + snmpEngine, 'my-nms', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (1), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) + +# *** SNMP engine configuration is complete by this line *** + +# Create default SNMP context where contextEngineId == SnmpEngineId +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Build and submit notification message to dispatcher +ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # TRAP OID + ('SNMPv2-MIB', 'coldStart') +) + +print('Notification is scheduled to be sent') + +# Run I/O dispatcher which would send pending message and stop +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/trap-v1.py b/examples/v3arch/agent/ntforg/trap-v1.py new file mode 100644 index 0000000..62974ed --- /dev/null +++ b/examples/v3arch/agent/ntforg/trap-v1.py @@ -0,0 +1,97 @@ +# +# Notification Originator +# +# Send SNMP notification using the following options: +# +# * SNMPv1 +# * with community name 'public' +# * over IPv4/UDP +# * to a Manager at 127.0.0.1:162 +# * send TRAP notification +# * with TRAP ID 'coldStart' specified as an OID +# * include managed objects information: +# * overriding Uptime value with 12345 +# * overriding Agent Address with '127.0.0.1' +# * overriding Enterprise OID with 1.3.6.1.4.1.20408.4.1.1.2 +# * include managed object information '1.3.6.1.2.1.1.1.0' = 'my system' +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c +#from pysnmp import debug + +# Optional debugging ('all' enables full debugging) +#debug.setLogger(debug.Debug('acl', 'io', 'dsp', 'msgproc', 'secmod', 'app')) + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + +# Specify security settings per SecurityName (SNMPv1 -> 0) +config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 0) + +# Setup transport endpoint and bind it with security settings yielding +# a target name +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +config.addTargetAddr( + snmpEngine, 'my-nms', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (1), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) + +# *** SNMP engine configuration is complete by this line *** + +# Create default SNMP context where contextEngineId == SnmpEngineId +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Build and submit notification message to dispatcher +ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # TRAP OID: Generic Trap #6 (enterpriseSpecific) and Specific Trap 432 + '1.3.6.1.4.1.20408.4.1.1.2.0.432', + # additional var-binds + ( + # Uptime value with 12345 + (v2c.ObjectIdentifier('1.3.6.1.2.1.1.3.0'), + v2c.TimeTicks(12345)), + # Agent Address with '127.0.0.1' + (v2c.ObjectIdentifier('1.3.6.1.6.3.18.1.3.0'), + v2c.IpAddress('127.0.0.1')), + # Enterprise OID with 1.3.6.1.4.1.20408.4.1.1.2 + (v2c.ObjectIdentifier('1.3.6.1.6.3.1.1.4.3.0'), + v2c.ObjectIdentifier('1.3.6.1.4.1.20408.4.1.1.2')), + # managed object '1.3.6.1.2.1.1.1.0' = 'my system' + (v2c.ObjectIdentifier('1.3.6.1.2.1.1.1.0'), + v2c.OctetString('my system')) + ) +) + +print('Notification is scheduled to be sent') + +# Run I/O dispatcher which would send pending message and stop +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py b/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py new file mode 100644 index 0000000..8218195 --- /dev/null +++ b/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py @@ -0,0 +1,95 @@ +# +# Notification Originator +# +# Send SNMP TRAP notifications to multiple Managers using the +# following options: +# +# * SNMPv2c +# * with community name 'public' +# * over IPv4/UDP +# * send TRAP notification +# * to multiple Managers at 127.0.0.1:162, 127.0.0.2:162 +# * with TRAP ID 'coldStart' specified as an OID +# * include managed objects information: +# 1.3.6.1.2.1.1.1.0 = 'Example Notificator' +# 1.3.6.1.2.1.1.5.0 = 'Notificator Example' +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + +# Specify security settings per SecurityName (SNMPv2c -> 1) +config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1) + +# Setup transport endpoint and bind it with security settings yielding +# a target name +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +# First target +config.addTargetAddr( + snmpEngine, 'my-nms-1', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) +# Second target +config.addTargetAddr( + snmpEngine, 'my-nms-2', + udp.domainName, ('127.0.0.2', 162), + 'my-creds', + tagList='all-my-managers' +) +# Third target +config.addTargetAddr( + snmpEngine, 'my-nms-3', + udp.domainName, ('127.0.0.3', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +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 +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Build and submit notification message to dispatcher +ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # Trap OID (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')) ) +) + +print('Notifications are scheduled to be sent') + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/trap-v2c-multiple-targets.py b/examples/v3arch/agent/ntforg/trap-v2c-multiple-targets.py new file mode 100644 index 0000000..562f465 --- /dev/null +++ b/examples/v3arch/agent/ntforg/trap-v2c-multiple-targets.py @@ -0,0 +1,94 @@ +# +# Notification Originator +# +# Send SNMP TRAP notifications to multiple Managers using the +# following options: +# +# * SNMPv2c +# * with community name 'public' +# * over IPv4/UDP +# * send TRAP notification +# * to multiple Managers at 127.0.0.1:162, 127.0.0.2:162 +# * with TRAP ID 'coldStart' specified as an OID +# * include managed objects information: +# 1.3.6.1.2.1.1.1.0 = 'Example Notificator' +# 1.3.6.1.2.1.1.5.0 = 'Notificator Example' +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + +# Specify security settings per SecurityName (SNMPv2c -> 1) +config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1) + +# Setup transport endpoint and bind it with security settings yielding +# a target name +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +# First target +config.addTargetAddr( + snmpEngine, 'my-nms-1', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) +# Second target +config.addTargetAddr( + snmpEngine, 'my-nms-2', + udp.domainName, ('127.0.0.2', 162), + 'my-creds', + tagList='all-my-managers' +) +# Third target +config.addTargetAddr( + snmpEngine, 'my-nms-3', + udp.domainName, ('127.0.0.3', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM) +# to what targets (chosen by tag) and with what credentials. +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-creds', 'all-my-managers', 'trap' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +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 +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Build and submit notification message to dispatcher +ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # Trap OID (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')) ) +) + +print('Notifications are scheduled to be sent') + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py b/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py new file mode 100644 index 0000000..1a9aa65 --- /dev/null +++ b/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py @@ -0,0 +1,94 @@ +# +# Notification Originator +# +# Send SNMP TRAP notification using the following options: +# +# * SNMPv2c +# * with community name 'public' +# * over IPv4/UDP and UDP/IPv6 +# * send TRAP notification +# * to two Managers through different network transports +# * with TRAP ID 'coldStart' specified as an OID +# * include managed objects information: +# 1.3.6.1.2.1.1.1.0 = 'Example Notificator' +# 1.3.6.1.2.1.1.5.0 = 'Notificator Example' +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp, udp6 +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + +# Specify security settings per SecurityName (SNMPv2c -> 1) +config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1) + +# Setup transport endpoints and bind it with security settings yielding +# a target name: + +# UDP/IPv4 +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +config.addTargetAddr( + snmpEngine, 'my-nms-1', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) + +# UDP/IPv6 +config.addSocketTransport( + snmpEngine, + udp6.domainName, + udp6.Udp6SocketTransport().openClientMode() +) +config.addTargetAddr( + snmpEngine, 'my-nms-2', + udp6.domainName, ('::1', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +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 +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Build and submit notification message to dispatcher +ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # Trap OID (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')) ) +) + +print('Notification is scheduled to be sent') + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py b/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py new file mode 100644 index 0000000..ab7e76f --- /dev/null +++ b/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py @@ -0,0 +1,124 @@ +# +# Notification Originator +# +# Send SNMP TRAP notification using the following options: +# +# * SNMPv2c +# * with community name 'public' +# * over IPv4/UDP +# * send TRAP notification +# * to a Managers at 127.0.0.1:162 +# * with TRAP ID ACCOUNTING-CONTROL-MIB::acctngFileFull as MIB symbol +# +# The ACCOUNTING-CONTROL-MIB::acctngFileFull NOTIFICATION-TYPE implies +# including three other var-binds into the TRAP describing the incident +# occurred. These var-binds are: +# ACCOUNTING-CONTROL-MIB::acctngFileMaximumSize.0 +# ACCOUNTING-CONTROL-MIB::acctngFileNameSuffix.0 +# ACCOUNTING-CONTROL-MIB::acctngFileName.0 +# +# To run this example make sure to have ACCOUNTING-CONTROL-MIB.py in +# search path. +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c +from pysnmp import debug + +debug.setLogger(debug.Debug('app')) + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# Create default SNMP context where contextEngineId == SnmpEngineId +snmpContext = context.SnmpContext(snmpEngine) + +# +# Here we fill in some values for Managed Objects Instances (invoked +# later while building TRAP message) by NOTIFICATION-TYPE macro evaluation. +# In real Agent app, these values should already be initialized during +# Agent runtime. +# + +mibInstrumCtl = snmpContext.getMibInstrum('') +( MibScalarInstance, ) = mibInstrumCtl.mibBuilder.importSymbols( + 'SNMPv2-SMI', + 'MibScalarInstance' + ) +( acctngFileFull, + acctngFileMaximumSize, + acctngFileNameSuffix, + acctngFileName ) = mibInstrumCtl.mibBuilder.importSymbols( + 'ACCOUNTING-CONTROL-MIB', + 'acctngFileFull', + 'acctngFileMaximumSize', + 'acctngFileNameSuffix', + 'acctngFileName' + ) + +mibInstrumCtl.mibBuilder.exportSymbols( + '__ACCOUNTING-CONTROL-MIB', + MibScalarInstance(acctngFileMaximumSize.name, (0,), acctngFileMaximumSize.syntax.clone(123)), + MibScalarInstance(acctngFileNameSuffix.name, (0,), acctngFileNameSuffix.syntax.clone('.log')), + MibScalarInstance(acctngFileName.name, (0,), acctngFileName.syntax.clone('mylogfile')), +) + +# +# End of Agent's Managed Object Instances initialization +# + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + +# Specify security settings per SecurityName (SNMPv2c -> 1) +config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1) + +# Setup transport endpoints and bind it with security settings yielding +# a target name: + +# UDP/IPv4 +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +config.addTargetAddr( + snmpEngine, 'my-nms-1', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) + +# *** SNMP engine configuration is complete by this line *** + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Build and submit notification message to dispatcher +ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # Trap type + ('ACCOUNTING-CONTROL-MIB', 'acctngFileFull'), + # MIB scalar/table instances of NOTIFICATION-TYPE objects + instanceIndex=(0,) +) + +print('Notification is scheduled to be sent') + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/trap-v2c.py b/examples/v3arch/agent/ntforg/trap-v2c.py new file mode 100644 index 0000000..d05a3f3 --- /dev/null +++ b/examples/v3arch/agent/ntforg/trap-v2c.py @@ -0,0 +1,87 @@ +# +# Notification Originator +# +# Send SNMP TRAP notification using the following options: +# +# * SNMPv2c +# * with community name 'public' +# * over IPv4/UDP +# * send TRAP notification +# * to a Manager at 127.0.0.1:162 +# * with TRAP ID 'coldStart' specified as an OID +# * include managed objects information: +# 1.3.6.1.2.1.1.1.0 = 'Example Notificator' +# 1.3.6.1.2.1.1.5.0 = 'Notificator Example' +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + +# Specify security settings per SecurityName (SNMPv2c -> 1) +config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1) + +# Setup transport endpoint and bind it with security settings yielding +# a target name +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +config.addTargetAddr( + snmpEngine, 'my-nms', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +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 +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Error/confirmation reciever +def cbFun(sendRequestHandle, errorIndication, cbCtx): + print('Notification %s, status - %s' % ( + sendRequestHandle, errorIndication and errorIndication or 'delivered' + ) + ) + +# Build and submit notification message to dispatcher +ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # Trap OID (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')) ), + cbFun +) + +print('Notification is scheduled to be sent') + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/trap-v3.py b/examples/v3arch/agent/ntforg/trap-v3.py new file mode 100644 index 0000000..d3c07c5 --- /dev/null +++ b/examples/v3arch/agent/ntforg/trap-v3.py @@ -0,0 +1,82 @@ +# +# Notification Originator +# +# Send SNMP TRAP notification using the following options: +# +# * SNMPv3 +# * with user 'usr-md5-des', auth: MD5, priv DES +# * over IPv4/UDP +# * send TRAP notification +# * to a Manager at 127.0.0.1:162 +# * with TRAP ID 'warmStart' specified as an OID +# * include managed object information 1.3.6.1.2.1.1.5.0 = 'system name' +# +from pysnmp.entity import engine, config +from pysnmp.carrier.asynsock.dgram import udp +from pysnmp.entity.rfc3413 import ntforg, context +from pysnmp.proto.api import v2c + +# Create SNMP engine instance with specific (and locally unique) +# SnmpEngineId -- it must also be known to the receiving party +# and configured at its VACM users table. +snmpEngine = engine.SnmpEngine( + snmpEngineID=v2c.OctetString(hexValue='8000000001020304') +) + +# Add USM user +config.addV3User( + snmpEngine, 'usr-md5-des', + config.usmHMACMD5AuthProtocol, 'authkey1', + config.usmDESPrivProtocol, 'privkey1' +) +config.addTargetParams(snmpEngine, 'my-creds', 'usr-md5-des', 'authPriv') + +# Setup transport endpoint and bind it with security settings yielding +# a target name +config.addSocketTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +config.addTargetAddr( + snmpEngine, 'my-nms', + udp.domainName, ('127.0.0.1', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (3), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (), (), (1,3,6)) + +# *** SNMP engine configuration is complete by this line *** + +# Create default SNMP context where contextEngineId == SnmpEngineId +snmpContext = context.SnmpContext(snmpEngine) + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator(snmpContext) + +# Build and submit notification message to dispatcher +ntfOrg.sendNotification( + snmpEngine, + # Notification targets + 'my-notification', + # Trap OID (SNMPv2-MIB::coldStart) + (1,3,6,1,6,3,1,1,5,1), + # ( (oid, value), ... ) + ( ((1,3,6,1,2,1,1,5,0), v2c.OctetString('system name')), ) +) + +print('Notification is scheduled to be sent') + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() |