From ddc989155d58641cf32e6a1ef8a400f22f5d167c Mon Sep 17 00:00:00 2001 From: elie Date: Mon, 14 Sep 2015 05:20:24 +0000 Subject: * synchronous oneliner apps redesigned to offer Python generator-based API along with a more comprehensive set of accepted parameters. * massively documented (in Sphinx, NumPy style) --- .../asyncio/agent/cmdrsp/multiple-usm-users.py | 47 +++++++-------- .../asyncio/manager/ntfrcv/multiple-interfaces.py | 42 +++++++------- .../asyncore/agent/cmdrsp/alternative-mib-tree.py | 38 +++++++------ .../asyncore/agent/cmdrsp/custom-mib-controller.py | 36 ++++++------ .../asyncore/agent/cmdrsp/custom-snmp-engine-id.py | 34 +++++------ .../cmdrsp/implementing-scalar-mib-objects.py | 34 +++++------ .../agent/cmdrsp/implementing-snmp-table.py | 51 +++++++++-------- .../cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py | 36 ++++++------ .../agent/cmdrsp/listen-on-multiple-interfaces.py | 34 +++++------ .../listening-on-virtual-network-interface.py | 66 +++++++++++----------- .../agent/cmdrsp/multiple-snmp-communities.py | 35 ++++++------ .../asyncore/agent/cmdrsp/multiple-snmp-engines.py | 52 +++++++++-------- .../asyncore/agent/cmdrsp/multiple-usm-users.py | 40 ++++++------- .../agent/cmdrsp/observe-request-processing.py | 42 +++++++------- .../multiple-different-notifications-at-once.py | 46 +++++++++------ .../asyncore/agent/ntforg/send-custom-pdu.py | 34 ++++++----- .../ntforg/send-inform-to-multiple-managers.py | 46 +++++++++------ .../ntforg/send-notification-over-ipv4-and-ipv6.py | 41 +++++++++----- .../ntforg/send-packet-from-specific-address.py | 35 +++++++----- .../v3arch/asyncore/agent/ntforg/usm-md5-none.py | 32 ++++++----- examples/v3arch/asyncore/agent/ntforg/v1-trap.py | 44 ++++++++------- .../v3arch/asyncore/agent/ntforg/v2c-inform.py | 38 +++++++------ .../agent/ntforg/v2c-trap-via-notification-type.py | 52 +++++++++-------- examples/v3arch/asyncore/agent/ntforg/v2c-trap.py | 36 +++++++----- examples/v3arch/asyncore/agent/ntforg/v3-trap.py | 33 ++++++----- .../custom-contextengineid-and-contextname.py | 35 ++++++------ .../manager/cmdgen/custom-timeout-and-retries.py | 31 +++++----- .../manager/cmdgen/fetch-variables-over-ipv6.py | 31 +++++----- .../getbulk-fetch-scalar-and-table-variables.py | 33 ++++++----- .../manager/cmdgen/getbulk-multiple-oids-to-eom.py | 32 ++++++----- .../getnext-multiple-oids-and-resolve-with-mib.py | 31 +++++----- .../manager/cmdgen/getnext-multiple-oids-to-eom.py | 31 +++++----- .../manager/cmdgen/observe-request-processing.py | 37 ++++++------ .../v3arch/asyncore/manager/cmdgen/pull-subtree.py | 30 +++++----- .../cmdgen/send-packets-from-specific-interface.py | 33 ++++++----- .../manager/cmdgen/set-multiple-scalar-values.py | 29 +++++----- .../manager/cmdgen/spoof-source-address.py | 49 ++++++++-------- .../asyncore/manager/cmdgen/usm-sha-aes128.py | 28 ++++----- .../v3arch/asyncore/manager/cmdgen/usm-sha-none.py | 29 +++++----- examples/v3arch/asyncore/manager/cmdgen/v1-get.py | 27 ++++----- examples/v3arch/asyncore/manager/cmdgen/v2c-set.py | 28 ++++----- .../ntfrcv/determine-peer-network-address.py | 34 +++++------ .../manager/ntfrcv/multiple-network-interfaces.py | 36 ++++++------ .../manager/ntfrcv/multiple-network-transports.py | 38 +++++++------ .../asyncore/manager/ntfrcv/multiple-usm-users.py | 44 ++++++++------- .../manager/ntfrcv/observe-request-processing.py | 40 ++++++------- .../manager/ntfrcv/regexp-community-name.py | 52 +++++++++-------- .../proxy/command/udp6-to-udp4-conversion.py | 49 ++++++++-------- .../asyncore/proxy/command/v2c-to-v1-conversion.py | 49 ++++++++-------- .../asyncore/proxy/command/v2c-to-v3-conversion.py | 48 ++++++++-------- .../asyncore/proxy/command/v3-to-v2c-conversion.py | 48 ++++++++-------- .../cmdrsp/implementing-scalar-mib-objects.py | 36 ++++++------ .../twisted/agent/cmdrsp/multiple-interfaces.py | 36 ++++++------ .../agent/cmdrsp/multiple-snmp-communities.py | 36 ++++++------ .../twisted/agent/cmdrsp/multiple-usm-users.py | 43 +++++++------- .../twisted/manager/ntfrcv/multiple-interfaces.py | 39 +++++++------ .../twisted/manager/ntfrcv/multiple-usm-users.py | 44 ++++++++------- 57 files changed, 1198 insertions(+), 1012 deletions(-) (limited to 'examples/v3arch') diff --git a/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py b/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py index cdc264b5..b0b7e5bd 100644 --- a/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py +++ b/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py @@ -1,25 +1,28 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv3 -# * with USM user 'usr-md5-des', auth: MD5, priv DES or -# with USM user 'usr-sha-none', auth: SHA, no privacy -# with USM user 'usr-sha-aes128', auth: SHA, priv AES -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 -# * using asyncio network transport (available since Python 3.4) -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 -# $ snmpwalk -v3 -u usr-sha-none -l authNoPriv -a SHA -A authkey1 localhost .1.3.6 -# $ snmpwalk -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 localhost .1.3.6 -# -# Requires Python 3.4 and later! -# +""" +Multiple SNMP USM users ++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv3 +* with USM user: + - 'usr-md5-des', auth: MD5, priv DES or + - 'usr-sha-none', auth: SHA, no privacy + - 'usr-sha-aes128', auth: SHA, priv AES +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 +* using asyncio network transport (available since Python 3.4) + +Either of the following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 +| $ snmpwalk -v3 -u usr-sha-none -l authNoPriv -a SHA -A authkey1 localhost .1.3.6 +| $ snmpwalk -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 localhost .1.3.6 + +Requires Python 3.4 and later! + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncio.dgram import udp diff --git a/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py b/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py index a5fa2417..30dc5111 100644 --- a/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py +++ b/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py @@ -1,23 +1,25 @@ -# -# Notification Receiver -# -# Receive SNMP TRAP/INFORM messages with the following options: -# -# * SNMPv1/SNMPv2c -# * with SNMP community "public" -# * over IPv4/UDP, listening at 127.0.0.1:162 -# over IPv4/UDP, listening at 127.0.0.1:2162 -# * using Asyncio framework for network transport -# * print received data on stdout -# -# Either of the following Net-SNMP's commands will send notifications to this -# receiver: -# -# $ snmptrap -v2c -c public 127.0.0.1:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test -# $ snmpinform -v2c -c public 127.0.0.1:2162 123 1.3.6.1.6.3.1.1.5.1 -# -# Requires Python 3.4 and later! -# +""" +Serving multiple network interfaces ++++++++++++++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv1/SNMPv2c +* with SNMP community "public" +* over IPv4/UDP, listening at 127.0.0.1:162 + over IPv4/UDP, listening at 127.0.0.1:2162 +* using Asyncio framework for network transport +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v2c -c public 127.0.0.1:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test +| $ snmpinform -v2c -c public 127.0.0.1:2162 123 1.3.6.1.6.3.1.1.5.1 + +Requires Python 3.4 and later! + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncio.dgram import udp from pysnmp.entity.rfc3413 import ntfrcv diff --git a/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py b/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py index eabb989a..fa3bc6b5 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py @@ -1,21 +1,23 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv3 -# * with USM username usr-md5-none -# * using alternative set of Managed Objects addressed by -# contextEngineId: 8000000001020304, contextName: my-context -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v3 -u usr-md5-none -l authNoPriv -A authkey1 -E 8000000001020304 -n my-context 127.0.0.1 .1.3.6 -# $ snmpwalk -v3 -u usr-md5-none -l authNoPriv -A authkey1 -E 8000000001020304 127.0.0.1 .1.3.6 -# +""" +Serve non-default MIB tree +++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv3 +* with USM username usr-md5-none +* using alternative set of Managed Objects addressed by + contextEngineId: 8000000001020304, contextName: my-context +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 + +Either of the following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v3 -u usr-md5-none -l authNoPriv -A authkey1 -E 8000000001020304 -n my-context 127.0.0.1 .1.3.6 +| $ snmpwalk -v3 -u usr-md5-none -l authNoPriv -A authkey1 -E 8000000001020304 127.0.0.1 .1.3.6 + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py b/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py index 5fe26a7b..1711133d 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py @@ -1,20 +1,22 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv3 -# * with USM username usr-none-none -# * using alternative set of Managed Objects addressed by -# contextName: my-context -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 -# -# The following Net-SNMP's command will send GET request to this Agent: -# -# $ snmpget -v3 -u usr-none-none -l noAuthNoPriv -n my-context -Ir 127.0.0.1 sysDescr.0 -# +""" +Custom MIB Controller ++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv3 +* with USM username usr-none-none +* using alternative set of Managed Objects addressed by + contextName: my-context +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 + +The following Net-SNMP command will send GET request to this Agent: + +| $ snmpget -v3 -u usr-none-none -l noAuthNoPriv -n my-context -Ir 127.0.0.1 sysDescr.0 + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py b/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py index 4a58de34..e2452ca3 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py @@ -1,19 +1,21 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv3 -# * with SNMP EngineID: 8000000004030201 -# * with USM user 'usr-md5-des', auth: MD5, priv DES -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -e 8000000004030201 localhost .1.3.6 -# +""" +Specific SNMP Engine ID ++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv3 +* with SNMP EngineID: 8000000004030201 +* with USM user 'usr-md5-des', auth: MD5, priv DES +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 + +The following Net-SNMP command will walk this Agent: + +| $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -e 8000000004030201 localhost .1.3.6 + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py b/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py index 47610384..196ee9c2 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py @@ -1,19 +1,21 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv2c -# * with SNMP community "public" -# * serving custom Managed Object Instance defined within this script -# * allow read access only to the subtree where the custom MIB object resides -# * over IPv4/UDP, listening at 127.0.0.1:161 -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 -# +""" +Implementing scalar MIB objects ++++++++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv2c +* with SNMP community "public" +* serving custom Managed Object Instance defined within this script +* allow read access only to the subtree where the custom MIB object resides +* over IPv4/UDP, listening at 127.0.0.1:161 + +The following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 + +"""# import sys from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context diff --git a/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py b/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py index 9bb49205..bf6d0423 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py @@ -1,28 +1,29 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv2c -# * with SNMP community "public" -# * define a simple SNMP Table within a newly created EXAMPLE-MIB -# * pre-populate SNMP Table with a single row of values -# * allow read access only to the subtree where example SNMP Table resides -# * over IPv4/UDP, listening at 127.0.0.1:161 -# -# -# The following Net-SNMP's commands will populate and walk a table: -# -# $ snmpset -v2c -c public 127.0.0.1 1.3.6.6.1.5.2.97.98.99 s 'my value' -# $ snmpset -v2c -c public 127.0.0.1 1.3.6.6.1.5.4.97.98.99 i 4 -# $ snmpwalk -v2c -c public 127.0.0.1 1.3.6 -# -# ...while the following command will destroy the same row -# -# $ snmpset -v2c -c public 127.0.0.1 1.3.6.6.1.5.4.97.98.99 i 6 -# $ snmpwalk -v2c -c public 127.0.0.1 1.3.6 -# +""" +Implementing conceptual table ++++++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv2c +* with SNMP community "public" +* define a simple SNMP Table within a newly created EXAMPLE-MIB +* pre-populate SNMP Table with a single row of values +* allow read access only to the subtree where example SNMP Table resides +* over IPv4/UDP, listening at 127.0.0.1:161 + +The following Net-SNMP commands will populate and walk a table: + +| $ snmpset -v2c -c public 127.0.0.1 1.3.6.6.1.5.2.97.98.99 s 'my value' +| $ snmpset -v2c -c public 127.0.0.1 1.3.6.6.1.5.4.97.98.99 i 4 +| $ snmpwalk -v2c -c public 127.0.0.1 1.3.6 + +...while the following command will destroy the same row + +| $ snmpset -v2c -c public 127.0.0.1 1.3.6.6.1.5.4.97.98.99 i 6 +| $ snmpwalk -v2c -c public 127.0.0.1 1.3.6 + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py b/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py index f9115e77..24de0618 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py @@ -1,20 +1,22 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv2c -# * with SNMP community "public" -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 and -# over IPv6/UDP, listening at [::1]:161 -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 -# $ snmpwalk -v2c -c public udp6:[::1] .1.3.6 -# +""" +Serve multiple network transports ++++++++++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv2c +* with SNMP community "public" +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 and + over IPv6/UDP, listening at [::1]:161 + +Either of the following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 +| $ snmpwalk -v2c -c public udp6:[::1] .1.3.6 + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp, udp6 diff --git a/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py b/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py index 8d67802c..25beef3f 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py @@ -1,19 +1,21 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv2c -# * with SNMP community "public" -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 and 127.0.0.2:161 interfaces -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 -# $ snmpwalk -v2c -c public 127.0.0.2 .1.3.6 -# +""" +Listen on multiple network interfaces ++++++++++++++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv2c +* with SNMP community "public" +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 and 127.0.0.2:161 interfaces + +Either of the following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 +| $ snmpwalk -v2c -c public 127.0.0.2 .1.3.6 + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py b/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py index 55e282f4..1e862706 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py @@ -1,35 +1,37 @@ -# -# Command Responder -# -# Listen on all local IPv4 interfaces respond to SNMP GET/SET/GETNEXT/GETBULK -# queries with the following options: -# -# * SNMPv3 -# * with USM user 'usr-md5-des', auth: MD5, priv DES -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 0.0.0.0:161 -# * preserve local IP address when responding (Python 3.3+ required) -# -# The following Net-SNMP's command will walk this Agent: -# -# $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 -# -# In the situation when UDP responder receives a datagram targeted to -# a secondary (AKA virtial) IP interface or a non-local IP interface -# (e.g. routed through policy routing or iptables TPROXY facility), -# OS stack will by default put primary local IP interface address into -# the IP source field of the response IP packet. Such datagram may not -# reach the sender as either the sender itself or a stateful firewall -# somewhere in between would not be able to match response to original -# request. -# -# The following script solves this problem by preserving original request -# destination IP address and put it back into response IP packet's source -# address field. -# -# To respond from a non-local (e.g. spoofed) IP address, uncomment the -# .enableTransparent() method call and run this script as root. -# +""" +Running at secondary network interface +++++++++++++++++++++++++++++++++++++++ + +Listen on all local IPv4 interfaces respond to SNMP GET/SET/GETNEXT/GETBULK +queries with the following options: + +* SNMPv3 +* with USM user 'usr-md5-des', auth: MD5, priv DES +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 0.0.0.0:161 +* preserve local IP address when responding (Python 3.3+ required) + +The following Net-SNMP command will walk this Agent: + +| $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 + +In the situation when UDP responder receives a datagram targeted to +a secondary (AKA virtial) IP interface or a non-local IP interface +(e.g. routed through policy routing or iptables TPROXY facility), +OS stack will by default put primary local IP interface address into +the IP source field of the response IP packet. Such datagram may not +reach the sender as either the sender itself or a stateful firewall +somewhere in between would not be able to match response to original +request. + +The following script solves this problem by preserving original request +destination IP address and put it back into response IP packet's source +address field. + +To respond from a non-local (e.g. spoofed) IP address, uncomment the +.enableTransparent() method call and run this script as root. + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py b/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py index d7e3a4d0..5780025f 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py @@ -1,19 +1,22 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT queries with -# the following options: -# -# * SNMPv1 -# * with SNMP community "public" (read access) or "private" (write access) -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 -# -# The following Net-SNMP's commands will GET/SET a value at this Agent: -# -# $ snmpget -v1 -c public 127.0.0.1 SNMPv2-MIB::sysLocation.0 -# $ snmpset -v1 -c private 127.0.0.1 SNMPv2-MIB::sysLocation.0 s "far away" -# +""" +Multiple SNMP communities ++++++++++++++++++++++++++ + +Respond to SNMP GET/SET/GETNEXT queries with the following options: + +* SNMPv1 +* with SNMP community "public" (read access) or "private" (write access) +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 + +Allow read/write access to all objects in the same MIB subtree. + +The following Net-SNMP's commands will GET/SET a value at this Agent: + +| $ snmpget -v1 -c public 127.0.0.1 SNMPv2-MIB::sysLocation.0 +| $ snmpset -v1 -c private 127.0.0.1 SNMPv2-MIB::sysLocation.0 s "far away" + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py b/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py index 870363a5..0a7b3a20 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py @@ -1,28 +1,30 @@ -# -# Multiple Command Responders -# -# Run multiple SNMP Engines each with a complete Command Responder. -# Bind each SNMP Engine to a dedicated network transport endpoint: -# -# * IPv4/UDP, listening at 127.0.0.1:161 -# * IPv4/UDP, listening at 127.0.0.2:161 -# -# Each Command Responder will respond to SNMP GET/SET/GETNEXT/GETBULK -# queries with the following options: -# -# * SNMPv3 -# * with USM user 'usr-md5-des', auth: MD5, priv DES -# * allow read access to SNMPv2-MIB objects (1.3.6) -# * allow write access to SNMPv2-MIB objects (1.3.6.1.2.1) -# -# The following Net-SNMP commands will walk the first and the second -# Agent respectively: -# -# $ snmpwalk -Ob -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 127.0.0.1 usmUserEntry -# $ snmpwalk -Ob -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 127.0.0.2 usmUserEntry -# -# Notice differently configured snmpEngineId's in usmUserEntry columns. -# +""" +Multiple SNMP Engines ++++++++++++++++++++++ + +Run multiple SNMP Engines each with a complete Command Responder. +Bind each SNMP Engine to a dedicated network transport endpoint: + +* IPv4/UDP, listening at 127.0.0.1:161 +* IPv4/UDP, listening at 127.0.0.2:161 + +Each Command Responder will respond to SNMP GET/SET/GETNEXT/GETBULK +queries with the following options: + +* SNMPv3 +* with USM user 'usr-md5-des', auth: MD5, priv DES +* allow read access to SNMPv2-MIB objects (1.3.6) +* allow write access to SNMPv2-MIB objects (1.3.6.1.2.1) + +The following Net-SNMP commands will walk the first and the second +Agent respectively: + +| $ snmpwalk -Ob -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 127.0.0.1 usmUserEntry +| $ snmpwalk -Ob -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 127.0.0.2 usmUserEntry + +Notice differently configured snmpEngineId's in usmUserEntry columns. + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.proto import rfc1902 diff --git a/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py b/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py index 1f11a58f..150a0f48 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py @@ -1,22 +1,24 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv3 -# * with USM user 'usr-md5-des', auth: MD5, priv DES or -# with USM user 'usr-sha-none', auth: SHA, no privacy -# with USM user 'usr-sha-aes128', auth: SHA, priv AES -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 -# $ snmpwalk -v3 -u usr-sha-none -l authNoPriv -a SHA -A authkey1 localhost .1.3.6 -# $ snmpwalk -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 localhost .1.3.6 -# +""" +Multiple SNMP USM users ++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv3 +* with USM user 'usr-md5-des', auth: MD5, priv DES or + with USM user 'usr-sha-none', auth: SHA, no privacy + with USM user 'usr-sha-aes128', auth: SHA, priv AES +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 + +Either of the following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 +| $ snmpwalk -v3 -u usr-sha-none -l authNoPriv -a SHA -A authkey1 localhost .1.3.6 +| $ snmpwalk -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 localhost .1.3.6 + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py b/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py index 53dad9a5..d03c52c1 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py @@ -1,23 +1,25 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv3 -# * with USM user 'usr-md5-des', auth: MD5, priv DES or -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 -# * registers its own execution observer to snmpEngine -# -# The following Net-SNMP's command will walk this Agent: -# -# $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 -# -# This script will report some details on request processing as seen -# by rfc3412.receiveMessage() and rfc3412.returnResponsePdu() -# abstract interfaces. -# +""" +Observe SNMP engine operations +++++++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv3 +* with USM user 'usr-md5-des', auth: MD5, priv DES or +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 +* registers its own execution observer to snmpEngine + +The following Net-SNMP command will walk this Agent: + +| $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 + +This script will report some details on request processing as seen +by rfc3412.receiveMessage() and rfc3412.returnResponsePdu() +abstract interfaces. + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py b/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py index d8093ade..ab5f6413 100644 --- a/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py +++ b/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py @@ -1,21 +1,31 @@ -# -# 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' -# +""" +Notification over multiple SNMP versions +++++++++++++++++++++++++++++++++++++++++ + +Send SNMP INFORM notifications to multiple Managers using different +security settings: + +* 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' + +Functionally similar to: + +| $ snmpinform -v3 -l authPriv -u usr-md5-none -A authkey1 127.0.0.1 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' + +and + +| $ snmpinform -v2c -c public 127.0.0.2 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg diff --git a/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py b/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py index f1e67e86..10517547 100644 --- a/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py +++ b/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py @@ -1,17 +1,23 @@ -# -# 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 -# * initialize TRAP PDU with the following var-binds: -# 1.3.6.1.2.1.1.3.0 = 123 -# 1.3.6.1.6.3.1.1.4.1.0 = 1.3.6.1.6.3.1.1.5.1 -# +""" +Send crafted TRAP PDU ++++++++++++++++++++++ + +Initialize TRAP PDU and pass it over to unified SNMPv3 message processing +framework for further treatment. + +* SNMPv2c +* with community name 'public' +* over IPv4/UDP +* send TRAP notification +* initialize TRAP PDU with the following var-binds: + 1.3.6.1.2.1.1.3.0 = 123 + 1.3.6.1.6.3.1.1.4.1.0 = 1.3.6.1.6.3.1.1.5.1 + +Functionally similar to: + +| $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.6.3.1.1.5.1 0.0.0.0 1 0 123 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg diff --git a/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py b/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py index 5b994cf3..ce82f60c 100644 --- a/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py +++ b/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py @@ -1,19 +1,33 @@ -# -# 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' -# +""" +Notification to multiple addresses +++++++++++++++++++++++++++++++++++ + +Send SNMP TRAP notifications to multiple Managers using different +security settings: + +* 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' + +Functionally similar to: + +| $ snmptrap -v2c -c public 127.0.0.1 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' + +and + +| $ snmptrap -v2c -c public 127.0.0.2 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' + +and + +| $ snmptrap -v2c -c public 127.0.0.3 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg diff --git a/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py b/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py index e8b674d6..1c93e620 100644 --- a/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py +++ b/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py @@ -1,18 +1,29 @@ -# -# 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' -# +""" +Notification over multiple network protocols +++++++++++++++++++++++++++++++++++++++++++++ + +Send SNMP INFORM notifications to multiple Managers over different +network protocols: + +* 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' + +Functionally similar to: + +| $ snmptrap -v2c -c public udp:127.0.0.1 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' + +and + +| $ snmptrap -v2c -c public udp6:[::1] 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp, udp6 from pysnmp.entity.rfc3413 import ntforg diff --git a/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py b/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py index b99389ab..c7dfedb4 100644 --- a/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py +++ b/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py @@ -1,16 +1,22 @@ -# -# 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 61024 -# * send TRAP notification -# * with TRAP ID 'coldStart' specified as an OID -# +""" +Send packet from specific network interface/port +++++++++++++++++++++++++++++++++++++++++++++++++ + +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 61024 +* send TRAP notification +* with TRAP ID 'coldStart' specified as an OID + +Functionally similar to: + +| $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.6.3.1.1.5.1 0.0.0.0 1 0 0 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg @@ -20,7 +26,8 @@ from pysnmp.proto.api import v2c snmpEngine = engine.SnmpEngine() # SecurityName <-> CommunityName mapping -config.addV1System(snmpEngine, 'my-area', 'public', transportTag='all-my-managers') +config.addV1System(snmpEngine, 'my-area', 'public', + transportTag='all-my-managers') # Specify security settings per SecurityName (SNMPv1 -> 0) config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 0) diff --git a/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py b/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py index 6a888dfb..116d6794 100644 --- a/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py +++ b/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py @@ -1,16 +1,22 @@ -# -# 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' -# +""" +SNMPv3 INFORM, auth: MD5, privacy: none ++++++++++++++++++++++++++++++++++++++++ + +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' + +Functionally similar to: + +| $ snmpinform -v3 -l authNoPriv -u usr-md5-none -A authkey1 demo.snmplabs.com 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 = 'system name' + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg diff --git a/examples/v3arch/asyncore/agent/ntforg/v1-trap.py b/examples/v3arch/asyncore/agent/ntforg/v1-trap.py index 83500f24..226788a7 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v1-trap.py +++ b/examples/v3arch/asyncore/agent/ntforg/v1-trap.py @@ -1,28 +1,30 @@ -# -# 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' -# +""" +SNMPv1 TRAP ++++++++++++ + +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' + +Functionally similar to: + +| $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 6 432 12345 1.3.6.1.2.1.1.1.0 s 'my system' + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg 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() diff --git a/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py b/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py index dd10f851..026d36ff 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py +++ b/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py @@ -1,18 +1,24 @@ -# -# 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' -# +""" +INFORM notification ++++++++++++++++++++ + +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' + +Functionally similar to: + +| $ snmpinform -v2c -c public demo.snmplabs.com 12345 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example Notificator' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg @@ -37,7 +43,7 @@ config.addTransport( ) config.addTargetAddr( snmpEngine, 'my-nms', - udp.domainName, ('127.0.0.1', 162), + udp.domainName, ('195.218.195.228', 162), 'my-creds', tagList='all-my-managers' ) diff --git a/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py b/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py index 4124a393..b72c5a7d 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py +++ b/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py @@ -1,27 +1,31 @@ -# -# 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 IF-MIB::ifLink as MIB symbol -# -# The IF-MIB::ifLink NOTIFICATION-TYPE implies including four other -# var-binds into the notification message describing the incident -# occurred. These var-binds are: -# IF-MIB::ifIndex."x" -# IF-MIB::ifAdminStatus."x" -# IF-MIB::ifOperStatus."x" -# IF-MIB::ifDescr."x" -# -# Where "x" is MIB table index (instance index). -# -# To run this example make sure to have IF-MIB.py in search path. -# +""" +Sending notification with OBJECT's +++++++++++++++++++++++++++++++++++ + +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 IF-MIB::ifLink as MIB symbol + +The IF-MIB::ifLink NOTIFICATION-TYPE implies including four other +var-binds into the notification message describing the incident +occurred. These var-binds are: +IF-MIB::ifIndex."x" +IF-MIB::ifAdminStatus."x" +IF-MIB::ifOperStatus."x" +IF-MIB::ifDescr."x" + +Where "x" is MIB table index (instance index). + +Functionally similar to: + +| $ snmptrap -v2c -c public 127.0.0.1 0 1.3.6.1.6.3.1.1.5.3 IF-MIB::ifIndex."1" IF-MIB::ifAdminStatus."1" IF-MIB::ifOperStatus."1" IF-MIB::ifDescr."1" + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg diff --git a/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py index 1ada77b9..2a926d88 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py +++ b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py @@ -1,18 +1,24 @@ -# -# 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' -# +""" +SNMPv2c TRAP +++++++++++++ + +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' + +Functionally similar to: + +| $ snmptrap -v2c -c public 127.0.0.1 12345 1.3.6.1.4.1.20408.4.1.1.2 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg diff --git a/examples/v3arch/asyncore/agent/ntforg/v3-trap.py b/examples/v3arch/asyncore/agent/ntforg/v3-trap.py index db2c965a..d43fe271 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v3-trap.py +++ b/examples/v3arch/asyncore/agent/ntforg/v3-trap.py @@ -1,16 +1,23 @@ -# -# 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' -# +""" +SNMPv3 TRAP, auth: MD5, privacy: DES +++++++++++++++++++++++++++++++++++++ + +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' + +Functionally similar to: + +| $ snmptrap -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -e 800000000 +1020304 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s 'my system' + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntforg diff --git a/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py b/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py index 01fd25dd..e61e5389 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py +++ b/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py @@ -1,19 +1,22 @@ -# -# GET Command Generator -# -# Send a SNMP GET request -# with SNMPv3 with user 'usr-md5-none', SHA auth and no privacy protocols -# for MIB instance identified by -# contextEngineId: 0x80004fb805636c6f75644dab22cc, -# contextName: da761cfc8c94d3aceef4f60f049105ba -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for an OID in tuple form -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 -E 80004fb805636c6f75644dab22cc -n da761cfc8c94d3aceef4f60f049105ba -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 -# +""" +Custom ContextEngineId and ContextName +++++++++++++++++++++++++++++++++++++++ + +Send a SNMP GET request with the following options: + +* with SNMPv3 with user 'usr-md5-none', SHA auth and no privacy protocols +* for MIB instance identified by +* contextEngineId: 0x80004fb805636c6f75644dab22cc, +* contextName: da761cfc8c94d3aceef4f60f049105ba +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for an OID in tuple form + +This script performs similar to the following Net-SNMP command: + +| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 -E 80004fb805636c6f75644dab22cc -n da761cfc8c94d3aceef4f60f049105ba -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py b/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py index 5fbd3ebb..b91a4b63 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py +++ b/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py @@ -1,17 +1,20 @@ -# -# GET Command Generator -# -# Send a SNMP GET request -# with SNMPv2c, community 'public' -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# wait 3 seconds for response, retry 5 times (plus one initial attempt) -# for an OID in tuple form -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpget -v2c -c public -ObentU -r 5 -t 1 195.218.195.228 1.3.6.1.2.1.1.1.0 -# +""" +SNMPv2c, custom timeout ++++++++++++++++++++++++ + +Send a SNMP GET request: + +* with SNMPv2c, community 'public' +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* wait 3 seconds for response, retry 5 times (plus one initial attempt) +* for an OID in tuple form + +This script performs similar to the following Net-SNMP command: + +| $ snmpget -v2c -c public -ObentU -r 5 -t 1 195.218.195.228 1.3.6.1.2.1.1.1.0 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py b/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py index ebdcb8a2..1856d80e 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py +++ b/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py @@ -1,17 +1,20 @@ -# -# GETNEXT Command Generator -# -# Send a series of SNMP GETNEXT requests -# with SNMPv3 with user 'usr-md5-none', MD5 auth and no privacy protocols -# over IPv6/UDP -# to an Agent at [::1]:161 -# for two OIDs in tuple form -# stop on end-of-mib condition for both OIDs -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpwalk -v3 -l authNoPriv -u usr-md5-none -A authkey1 -ObentU udp6:[::1]:161 1.3.6.1.2.1.1 1.3.6.1.4.1.1 -# +""" +Walk Agent over IPv6 +++++++++++++++++++++ + +Send a series of SNMP GETNEXT requests with the following options: + +* with SNMPv3 with user 'usr-md5-none', MD5 auth and no privacy protocols +* over IPv6/UDP +* to an Agent at [::1]:161 +* for two OIDs in tuple form +* stop on end-of-mib condition for both OIDs + +This script performs similar to the following Net-SNMP command: + +| $ snmpwalk -v3 -l authNoPriv -u usr-md5-none -A authkey1 -ObentU udp6:[::1]:161 1.3.6.1.2.1.1 1.3.6.1.4.1.1 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp6 from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py b/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py index 934fcd67..8bd04a5c 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py +++ b/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py @@ -1,18 +1,21 @@ -# -# GETBULK Command Generator -# -# Send a series of SNMP GETBULK requests -# with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# with values non-repeaters = 1, max-repetitions = 25 -# for two OIDs in tuple form (first OID is non-repeating) -# stop on end-of-mib condition for both OIDs -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpbulkwalk -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -C n1 -C r25 -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 -# +""" +Fetch scalar and table variables +++++++++++++++++++++++++++++++++ + +Send a series of SNMP GETBULK requests with the following options: + +* with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* with values non-repeaters = 1, max-repetitions = 25 +* for two OIDs in tuple form (first OID is non-repeating) +* stop on end-of-mib condition for both OIDs + +This script performs similar to the following Net-SNMP command: + +| $ snmpbulkwalk -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -C n1 -C r25 -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdgen from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py b/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py index 6c451a30..9f5db70c 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py +++ b/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py @@ -1,18 +1,20 @@ -# -# GETBULK Command Generator -# -# Send a series of SNMP GETBULK requests -# with SNMPv2c, community 'public' -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# with values non-repeaters = 0, max-repetitions = 25 -# for two OIDs in tuple form -# stop on end-of-mib condition for both OIDs -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpbulkwalk -v2c -c public -C n0 -C r25 -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 -# +""" +Bulk walk MIB ++++++++++++++ + +Send a series of SNMP GETBULK requests +* with SNMPv2c, community 'public' +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* with values non-repeaters = 0, max-repetitions = 25 +* for two OIDs in tuple form +* stop on end-of-mib condition for both OIDs + +This script performs similar to the following Net-SNMP command: + +| $ snmpbulkwalk -v2c -c public -C n0 -C r25 -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 + +"""# from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdgen from pysnmp.carrier.asyncore.dgram import udp diff --git a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py index 59e0bba9..d69abfeb 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py +++ b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py @@ -1,17 +1,20 @@ -# -# GETNEXT Command Generator -# -# Send a series of SNMP GETNEXT requests -# with SNMPv1, community 'public' -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for two OIDs in tuple form -# stop on end-of-mib condition for both OIDs -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpwalk -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 -# +""" +Walk Agent and resolve variables at MIB ++++++++++++++++++++++++++++++++++++++++ + +Send a series of SNMP GETNEXT requests with the following options: + +* with SNMPv1, community 'public' +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for two OIDs in tuple form +* stop on end-of-mib condition for both OIDs + +This script performs similar to the following Net-SNMP command: + +| $ snmpwalk -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py index 5d4420c6..0a41a416 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py +++ b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py @@ -1,17 +1,20 @@ -# -# GETNEXT Command Generator -# -# Send a series of SNMP GETNEXT requests -# with SNMPv1, community 'public' -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for two OIDs in tuple form -# stop on end-of-mib condition for both OIDs -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpwalk -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 -# +""" +Fetch two subtrees in parallel +++++++++++++++++++++++++++++++ + +Send a series of SNMP GETNEXT requests with the following options: + +* with SNMPv1, community 'public' +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for two OIDs in tuple form +* stop on end-of-mib condition for both OIDs + +This script performs similar to the following Net-SNMP command: + +| $ snmpwalk -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py b/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py index d05be2d5..0914ac36 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py +++ b/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py @@ -1,20 +1,23 @@ -# -# GET Command Generator -# -# Send a SNMP GET request -# with SNMPv3 with user 'usr-sha-aes', SHA auth and AES128 privacy protocols -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for an OID in tuple form -# also registers its own execution observer to snmpEngine -# -# While execution, this script will report some details on request processing -# as seen by rfc3412.sendPdu() and rfc3412.receiveMessage() abstract interfaces. -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpget -v3 -l authPriv -u usr-sha-aes -a SHA -A authkey1 -x AES -X privkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 -# +""" +Report SNMP engine processing details ++++++++++++++++++++++++++++++++++++++ + +Send SNMP GET request with the following options: + +* with SNMPv3 with user 'usr-sha-aes', SHA auth and AES128 privacy protocols +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for an OID in tuple form +* also registers its own execution observer to snmpEngine + +While execution, this script will report some details on request processing +as seen by rfc3412.sendPdu() and rfc3412.receiveMessage() abstract interfaces. + +This script performs similar to the following Net-SNMP command: + +| $ snmpget -v3 -l authPriv -u usr-sha-aes -a SHA -A authkey1 -x AES -X privkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py b/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py index abf3bab5..5edc744e 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py +++ b/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py @@ -1,17 +1,19 @@ -# -# GETNEXT Command Generator -# -# Send a series of SNMP GETNEXT requests -# with SNMPv3 with user 'usr-none-none', no auth and no privacy protocols -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for an OID in string form -# stop whenever received OID goes out of initial prefix (it may be a table) -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpwalk -v3 -l noAuthNoPriv -u usr-none-none -ObentU 195.218.195.228:161 1.3.6.1.2.1.1 -# +""" +Pull MIB subtree +++++++++++++++++ + +Send a series of SNMP GETNEXT requests +* with SNMPv3 with user 'usr-none-none', no auth and no privacy protocols +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for an OID in string form +* stop whenever received OID goes out of initial prefix (it may be a table) + +This script performs similar to the following Net-SNMP command: + +| $ snmpwalk -v3 -l noAuthNoPriv -u usr-none-none -ObentU 195.218.195.228:161 1.3.6.1.2.1.1 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py b/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py index 4ce98774..022742a7 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py +++ b/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py @@ -1,18 +1,21 @@ -# -# GETNEXT Command Generator -# -# Send a series of SNMP GETNEXT requests -# with SNMPv2c, community 'public' -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# sending packets from primary local interface 0.0.0.0, local port 61024 -# for two OIDs in tuple form -# stop on end-of-mib condition for both OIDs -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpwalk -v2c -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 -# +""" +Send packets from specific local interface +++++++++++++++++++++++++++++++++++++++++++ + +Send a series of SNMP GETNEXT requests with the following options: + +* with SNMPv2c, community 'public' +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* sending packets from primary local interface 0.0.0.0, local port 61024 +* for two OIDs in tuple form +* stop on end-of-mib condition for both OIDs + +This script performs similar to the following Net-SNMP command: + +| $ snmpwalk -v2c -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py b/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py index 05e82926..55a87202 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py +++ b/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py @@ -1,16 +1,19 @@ -# -# SET Command Generator -# -# Send a SNMP SET request -# with SNMPv1 with community name 'private' -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for OIDs in tuple form and an integer and string-typed values -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpset -v1 -c private -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.3.1 s 'my value' 1.3.6.1.2.1.1.9.1.4.1 t 123 -# +""" +SET string and integer scalars +++++++++++++++++++++++++++++++ + +Send SNMP SET request with the following options: + +* with SNMPv1 with community name 'private' +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for OIDs in tuple form and an integer and string-typed values + +This script performs similar to the following Net-SNMP command: + +| $ snmpset -v1 -c private -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.3.1 s 'my value' 1.3.6.1.2.1.1.9.1.4.1 t 123 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py b/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py index cab29126..998d40f4 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py +++ b/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py @@ -1,27 +1,28 @@ -# -# GET Command Generator -# -# Send a SNMP GET request -# with SNMPv2c, community 'public' -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# from a non-local, spoofed IP 1.2.3.4 (root and Python 3.3+ required) -# for an OID in tuple form -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpget -v2c -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.1.0 -# -# But unlike the above command, this script issues SNMP request from -# a non-default, non-local IP address. -# -# It is indeed possible to originate SNMP traffic from any valid local -# IP addresses. It could be a secondary IP interface, for instance. -# Superuser privileges are only required to send spoofed packets. -# Alternatively, sending from local interface could also be achieved by -# binding to it (via openClientMode() parameter). -# -# +""" +Spoof source address +++++++++++++++++++++ + +Send a SNMP GET request +* with SNMPv2c, community 'public' +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* from a non-local, spoofed IP 1.2.3.4 (root and Python 3.3+ required) +* for an OID in tuple form + +This script performs similar to the following Net-SNMP command: + +| $ snmpget -v2c -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.1.0 + +But unlike the above command, this script issues SNMP request from +a non-default, non-local IP address. + +It is indeed possible to originate SNMP traffic from any valid local +IP addresses. It could be a secondary IP interface, for instance. +Superuser privileges are only required to send spoofed packets. +Alternatively, sending from local interface could also be achieved by +binding to it (via openClientMode() parameter). + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py index 98205432..f7ff4ee5 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py +++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py @@ -1,16 +1,18 @@ -# -# GET Command Generator -# -# Send a SNMP GET request -# with SNMPv3 with user 'usr-sha-aes', SHA auth and AES128 privacy protocols -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for an OID in tuple form -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpget -v3 -l authPriv -u usr-sha-aes -a SHA -A authkey1 -x AES -X privkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 -# +""" +SNMPv3, auth: SHA, privacy: AES128 +++++++++++++++++++++++++++++++++++ + +Send a SNMP GET request +* with SNMPv3 with user 'usr-sha-aes', SHA auth and AES128 privacy protocols +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for an OID in tuple form + +This script performs similar to the following Net-SNMP command: + +| $ snmpget -v3 -l authPriv -u usr-sha-aes -a SHA -A authkey1 -x AES -X privkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py index 790fb3f3..1c39d33d 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py +++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py @@ -1,16 +1,19 @@ -# -# SET Command Generator -# -# Send a SNMP SET request -# with SNMPv3 with user 'usr-sha-none', SHA auth and no privacy protocols -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for an OID in tuple form and a string-typed value -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpset -v3 -l authNoPriv -u usr-sha-none -a SHA -A authkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.3.1 s 'my new value' -# +""" +Set string value +++++++++++++++++ + +Send a SNMP SET request with the following options: + +* with SNMPv3 with user 'usr-sha-none', SHA auth and no privacy protocols +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for an OID in tuple form and a string-typed value + +This script performs similar to the following Net-SNMP command: + +| $ snmpset -v3 -l authNoPriv -u usr-sha-none -a SHA -A authkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.3.1 s 'my new value' + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/v1-get.py b/examples/v3arch/asyncore/manager/cmdgen/v1-get.py index af54eb8f..234d414f 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/v1-get.py +++ b/examples/v3arch/asyncore/manager/cmdgen/v1-get.py @@ -1,16 +1,17 @@ -# -# GET Command Generator -# -# Send a SNMP GET request -# with SNMPv1, community 'public' -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for an OID in tuple form -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpget -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.1.0 -# +""" +SNMPv1 +++++++ + +* with SNMPv1, community 'public' +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for an OID in tuple form + +This script performs similar to the following Net-SNMP command: + +| $ snmpget -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.1.0 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py b/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py index 620ededa..9f7068fb 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py +++ b/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py @@ -1,16 +1,18 @@ -# -# SET Command Generator -# -# Send a SNMP SET request -# with SNMPv2c with community name 'private' -# over IPv4/UDP -# to an Agent at 195.218.195.228:161 -# for an OID in tuple form and an integer-typed value -# -# This script performs similar to the following Net-SNMP command: -# -# $ snmpset -v2c -c private -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.4.1 t 123 -# +""" +Set scalar value +++++++++++++++++ + +Send a SNMP SET request +* with SNMPv2c with community name 'private' +* over IPv4/UDP +* to an Agent at 195.218.195.228:161 +* for an OID in tuple form and an integer-typed value + +This script performs similar to the following Net-SNMP command: + +| $ snmpset -v2c -c private -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.4.1 t 123 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import cmdgen diff --git a/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py b/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py index ea3aafbc..d8619def 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py @@ -1,19 +1,21 @@ -# -# Notification Receiver -# -# Receive SNMP TRAP/INFORM messages with the following options: -# -# * SNMPv1/SNMPv2c -# * with SNMP community "public" -# * over IPv4/UDP, listening at 127.0.0.1:162 -# * use observer facility to pull lower-level request details from SNMP engine -# * print received data on stdout -# -# Either of the following Net-SNMP's commands will send notifications to this -# receiver: -# -# $ snmptrap -v2c -c public 127.0.0.1:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test -# +""" +Receive notifications noting peer address ++++++++++++++++++++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv1/SNMPv2c +* with SNMP community "public" +* over IPv4/UDP, listening at 127.0.0.1:162 +* use observer facility to pull lower-level request details from SNMP engine +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v2c -c public 127.0.0.1:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntfrcv diff --git a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py index c4dbae85..402f9308 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py @@ -1,20 +1,22 @@ -# -# Notification Receiver -# -# Receive SNMP TRAP/INFORM messages with the following options: -# -# * SNMPv1/SNMPv2c -# * with SNMP community "public" -# * over IPv4/UDP, listening at 127.0.0.1:162 -# over IPv4/UDP, listening at 127.0.0.1:2162 -# * print received data on stdout -# -# Either of the following Net-SNMP's commands will send notifications to this -# receiver: -# -# $ snmptrap -v2c -c public 127.0.0.1:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test -# $ snmpinform -v2c -c public 127.0.0.1:2162 123 1.3.6.1.6.3.1.1.5.1 -# +""" +Serving multiple network interfaces ++++++++++++++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv1/SNMPv2c +* with SNMP community "public" +* over IPv4/UDP, listening at 127.0.0.1:162 + over IPv4/UDP, listening at 127.0.0.1:2162 +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v2c -c public 127.0.0.1:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test +| $ snmpinform -v2c -c public 127.0.0.1:2162 123 1.3.6.1.6.3.1.1.5.1 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntfrcv diff --git a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py index 2b549986..31fcb2b5 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py @@ -1,21 +1,23 @@ -# -# Notification Receiver -# -# Receive SNMP TRAP/INFORM messages with the following options: -# -# * SNMPv1/SNMPv2c -# * with SNMP community "public" -# * over IPv4/UDP, listening at 127.0.0.1:162 -# over IPv6/UDP, listening at [::1]:162 -# * print received data on stdout -# -# Either of the following Net-SNMP's commands will send notifications to this -# receiver: -# -# $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test -# $ snmptrap -v2c -c public udp6:[::1]:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test -# $ snmpinform -v2c -c public 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 -# +""" +Using multiple network transports ++++++++++++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv1/SNMPv2c +* with SNMP community "public" +* over IPv4/UDP, listening at 127.0.0.1:162 + over IPv6/UDP, listening at [::1]:162 +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test +| $ snmptrap -v2c -c public udp6:[::1]:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test +| $ snmpinform -v2c -c public 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp, udp6 from pysnmp.entity.rfc3413 import ntfrcv diff --git a/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py b/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py index f78d11c8..037062b9 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py @@ -1,23 +1,27 @@ -# -# Notification Receiver -# -# Receive SNMP TRAP/INFORM messages with the following options: -# -# * SNMPv3 -# * with USM users: -# 'usr-md5-des', auth: MD5, priv DES, ContextEngineId: 8000000001020304 -# 'usr-md5-none', auth: MD5, priv NONE, ContextEngineId: 8000000001020304 -# 'usr-sha-aes128', auth: SHA, priv AES, ContextEngineId: 8000000001020304 -# * over IPv4/UDP, listening at 127.0.0.1:162 -# * print received data on stdout -# -# Either of the following Net-SNMP's commands will send notifications to this -# receiver: -# -# $ snmptrap -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -e 8000000001020304 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 -# $ snmptrap -v3 -u usr-md5-none -l authNoPriv -A authkey1 -e 8000000001020304 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 -# $ snmpinform -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 -# +""" +Multiple SNMP USM users ++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv3 +* with USM users: + + * 'usr-md5-des', auth: MD5, priv DES, ContextEngineId: 8000000001020304 + * 'usr-md5-none', auth: MD5, priv NONE, ContextEngineId: 8000000001020304 + * 'usr-sha-aes128', auth: SHA, priv AES, ContextEngineId: 8000000001020304 + +* over IPv4/UDP, listening at 127.0.0.1:162 +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -e 8000000001020304 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 +| $ snmptrap -v3 -u usr-md5-none -l authNoPriv -A authkey1 -e 8000000001020304 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 +| $ snmpinform -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntfrcv diff --git a/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py b/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py index 5651a6f7..ed44146c 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py @@ -1,22 +1,24 @@ -# -# Notification Receiver -# -# Receive SNMP TRAP/INFORM messages with the following options: -# -# * SNMPv1/SNMPv2c -# * with SNMP community "public" -# * over IPv4/UDP, listening at 127.0.0.1:162 -# over IPv6/UDP, listening at [::1]:162 -# * registers its own execution observer to snmpEngine -# * print received data on stdout -# -# Either of the following Net-SNMP's commands will send notifications to this -# receiver: -# -# $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test -# $ snmptrap -v2c -c public udp6:[::1]:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test -# $ snmpinform -v2c -c public 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 -# +""" +Observe SNMP engine internal operations ++++++++++++++++++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv1/SNMPv2c +* with SNMP community "public" +* over IPv4/UDP, listening at 127.0.0.1:162 + over IPv6/UDP, listening at [::1]:162 +* registers its own execution observer to snmpEngine +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test +| $ snmptrap -v2c -c public udp6:[::1]:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test +| $ snmpinform -v2c -c public 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp, udp6 from pysnmp.entity.rfc3413 import ntfrcv diff --git a/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py b/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py index 57a70308..759bf980 100644 --- a/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py +++ b/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py @@ -1,28 +1,30 @@ -# -# Notification Receiver -# -# Receive SNMP TRAP/INFORM messages with the following options: -# -# * SNMPv1/SNMPv2c -# * with any SNMP community matching regexp '.*love.*' -# * over IPv4/UDP, listening at 127.0.0.1:162 -# * print received data on stdout -# -# Either of the following Net-SNMP's commands will send notifications to this -# receiver: -# -# $ snmptrap -v1 -c rollover 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test -# $ snmpinform -v2c -c glove 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 -# -# The Notification Receiver below taps on v1/v2c SNMP security module -# to deliver certains values, normally internal to SNMP Engine, up to -# the context of user application. -# -# This script examines the value of CommunityName, as it came from peer SNMP -# Engine, and may modify it to match the only locally configured CommunityName -# 'public'. This effectively makes NotificationReceiver accepting messages with -# CommunityName's, not explicitly configured to local SNMP Engine. -# +""" +Serve SNMP Community names defined by regexp +++++++++++++++++++++++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv1/SNMPv2c +* with any SNMP community matching regexp '.*love.*' +* over IPv4/UDP, listening at 127.0.0.1:162 +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v1 -c rollover 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test +| $ snmpinform -v2c -c glove 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 + +The Notification Receiver below taps on v1/v2c SNMP security module +to deliver certains values, normally internal to SNMP Engine, up to +the context of user application. + +This script examines the value of CommunityName, as it came from peer SNMP +Engine, and may modify it to match the only locally configured CommunityName +'public'. This effectively makes NotificationReceiver accepting messages with +CommunityName's, not explicitly configured to local SNMP Engine. + +"""# from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntfrcv diff --git a/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py b/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py index 07497b4e..a13df6b6 100644 --- a/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py +++ b/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py @@ -1,26 +1,29 @@ -# -# SNMP Command Proxy example -# -# Act as a local SNMPv1/v2c Agent listening on a UDP/IPv6 transport, relay -# messages to distant SNMPv1/2c Agent over UDP/IPv4 transport: -# with local SNMPv2c community 'public' -# local Agent listening at [::1]:161 -# remote SNMPv2c community 'public' -# remote Agent listening at 195.218.195.228:161 -# -# This script can be queried with the following Net-SNMP command: -# -# $ snmpget -v2c -c public udp6:[::1]:161 sysDescr.0 -# -# due to proxy, it is equivalent to -# -# $ snmpget -v2c -c public 195.218.195.228:161 sysDescr.0 -# -# Warning: for production operation you would need to modify this script -# so that it will re-map possible duplicate request-ID values, coming in -# initial request PDUs from different Managers, into unique values to -# avoid sending duplicate request-IDs to Agents. -# +""" +IPv6-to-IPv4 conversion ++++++++++++++++++++++++ + +Act as a local SNMPv1/v2c Agent listening on a UDP/IPv6 transport, relay +messages to distant SNMPv1/2c Agent over UDP/IPv4 transport: + +* with local SNMPv2c community 'public' +* local Agent listening at [::1]:161 +* remote SNMPv2c community 'public' +* remote Agent listening at 195.218.195.228:161 + +This script can be queried with the following Net-SNMP command: + +| $ snmpget -v2c -c public udp6:[::1]:161 sysDescr.0 + +due to proxy, it is equivalent to + +| $ snmpget -v2c -c public 195.218.195.228:161 sysDescr.0 + +Warning: for production operation you would need to modify this script +so that it will re-map possible duplicate request-ID values, coming in +initial request PDUs from different Managers, into unique values to +avoid sending duplicate request-IDs to Agents. + +"""# from pysnmp.carrier.asyncore.dgram import udp, udp6 from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, cmdgen, context diff --git a/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py b/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py index e6a805c6..4e78dfca 100644 --- a/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py +++ b/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py @@ -1,26 +1,29 @@ -# -# SNMP Command Proxy example -# -# Act as a local SNMPv2c Agent, relay messages to distant SNMPv1 Agent: -# over IPv4/UDP -# with local SNMPv2c community public -# local Agent listening at 127.0.0.1:161 -# remote SNMPv1, community public -# remote Agent listening at 195.218.195.228:161 -# -# This script can be queried with the following Net-SNMP command: -# -# $ snmpbulkwalk -v2c -c public -ObentU 127.0.0.1:161 system -# -# due to proxy, it is equivalent to -# -# $ snmpwalk -v1 -c public 195.218.195.228:161 system -# -# Warning: for production operation you would need to modify this script -# so that it will re-map possible duplicate request-ID values, coming in -# initial request PDUs from different Managers, into unique values to -# avoid sending duplicate request-IDs to Agents. -# +""" +SNMPv2c-to-SNMPv1 conversion +++++++++++++++++++++++++++++ + +Act as a local SNMPv2c Agent, relay messages to distant SNMPv1 Agent: + +* over IPv4/UDP +* with local SNMPv2c community public +* local Agent listening at 127.0.0.1:161 +* remote SNMPv1, community public +* remote Agent listening at 195.218.195.228:161 + +This script can be queried with the following Net-SNMP command: + +| $ snmpbulkwalk -v2c -c public -ObentU 127.0.0.1:161 system + +due to proxy, it is equivalent to + +| $ snmpwalk -v1 -c public 195.218.195.228:161 system + +Warning: for production operation you would need to modify this script +so that it will re-map possible duplicate request-ID values, coming in +initial request PDUs from different Managers, into unique values to +avoid sending duplicate request-IDs to Agents. + +"""# from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, cmdgen, context diff --git a/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py b/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py index 453d8bb5..ca269f73 100644 --- a/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py +++ b/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py @@ -1,26 +1,28 @@ -# -# SNMP Command Proxy example -# -# Act as a local SNMPv1/v2c Agent, relay messages to distant SNMPv3 Agent: -# over IPv4/UDP -# with local SNMPv2c community 'public' -# local Agent listening at 127.0.0.1:161 -# remote SNMPv3 user usr-md5-none, MD5 auth and no privacy protocols -# remote Agent listening at 195.218.195.228:161 -# -# This script can be queried with the following Net-SNMP command: -# -# $ snmpget -v2c -c public 127.0.0.1:161 1.3.6.1.2.1.1.1.0 -# -# due to proxy, it is equivalent to -# -# $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 -# -# Warning: for production operation you would need to modify this script -# so that it will re-map possible duplicate request-ID values, coming in -# initial request PDUs from different Managers, into unique values to -# avoid sending duplicate request-IDs to Agents. -# +""" +SNMPv2c-to-SNMPv3 conversion +++++++++++++++++++++++++++++ + +Act as a local SNMPv1/v2c Agent, relay messages to distant SNMPv3 Agent: +* over IPv4/UDP +* with local SNMPv2c community 'public' +* local Agent listening at 127.0.0.1:161 +* remote SNMPv3 user usr-md5-none, MD5 auth and no privacy protocols +* remote Agent listening at 195.218.195.228:161 + +This script can be queried with the following Net-SNMP command: + +| $ snmpget -v2c -c public 127.0.0.1:161 1.3.6.1.2.1.1.1.0 + +due to proxy, it is equivalent to + +| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 + +Warning: for production operation you would need to modify this script +so that it will re-map possible duplicate request-ID values, coming in +initial request PDUs from different Managers, into unique values to +avoid sending duplicate request-IDs to Agents. + +"""# from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, cmdgen, context diff --git a/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py b/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py index 992ff7fb..da9aba3e 100644 --- a/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py +++ b/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py @@ -1,26 +1,28 @@ -# -# SNMP Command Proxy example -# -# Act as a local SNMPv3 Agent, relay messages to distant SNMPv1/v2c Agent: -# over IPv4/UDP -# with local SNMPv3 user usr-md5-des, MD5 auth and DES privacy protocols -# local Agent listening at 127.0.0.1:161 -# remote SNMPv1, community public -# remote Agent listening at 195.218.195.228:161 -# -# This script can be queried with the following Net-SNMP command: -# -# $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -ObentU 127.0.0.1:161 1.3.6.1.2.1.1.1.0 -# -# due to proxy, it is equivalent to -# -# $ snmpget -v2c -c public 195.218.195.228:161 1.3.6.1.2.1.1.1.0 -# -# Warning: for production operation you would need to modify this script -# so that it will re-map possible duplicate request-ID values, coming in -# initial request PDUs from different Managers, into unique values to -# avoid sending duplicate request-IDs to Agents. -# +""" +SNMPv3-to-SNMPv2c conversion +++++++++++++++++++++++++++++ + +Act as a local SNMPv3 Agent, relay messages to distant SNMPv1/v2c Agent: +* over IPv4/UDP +* with local SNMPv3 user usr-md5-des, MD5 auth and DES privacy protocols +* local Agent listening at 127.0.0.1:161 +* remote SNMPv1, community public +* remote Agent listening at 195.218.195.228:161 + +This script can be queried with the following Net-SNMP command: + +| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -ObentU 127.0.0.1:161 1.3.6.1.2.1.1.1.0 + +due to proxy, it is equivalent to + +| $ snmpget -v2c -c public 195.218.195.228:161 1.3.6.1.2.1.1.1.0 + +Warning: for production operation you would need to modify this script +so that it will re-map possible duplicate request-ID values, coming in +initial request PDUs from different Managers, into unique values to +avoid sending duplicate request-IDs to Agents. + +"""# from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, cmdgen, context diff --git a/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py b/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py index 091bb755..565419d4 100644 --- a/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py +++ b/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py @@ -1,20 +1,22 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv2c -# * with SNMP community "public" -# * serving custom Managed Object Instance defined within this script -# * allow read access only to the subtree where the custom MIB object resides -# * over IPv4/UDP, listening at 127.0.0.1:161 -# * using Twisted fraework for network transport -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 -# +""" +Implementing scalar MIB objects ++++++++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv2c +* with SNMP community "public" +* serving custom Managed Object Instance defined within this script +* allow read access only to the subtree where the custom MIB object resides +* over IPv4/UDP, listening at 127.0.0.1:161 +* using Twisted fraework for network transport + +Either of the following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 + +"""# import sys from twisted.internet import reactor from pysnmp.entity import engine, config diff --git a/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py b/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py index 4f8b29de..a9e3e002 100644 --- a/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py +++ b/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py @@ -1,20 +1,22 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv2c -# * with SNMP community "public" -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 and 127.0.0.2:161 interfaces -# * using Twisted framework for network transport -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 -# $ snmpwalk -v2c -c public 127.0.0.2 .1.3.6 -# +""" +Listen on multiple network interfaces ++++++++++++++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv2c +* with SNMP community "public" +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 and 127.0.0.2:161 interfaces +* using Twisted framework for network transport + +Either of the following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 +| $ snmpwalk -v2c -c public 127.0.0.2 .1.3.6 + +"""# from twisted.internet import reactor from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context diff --git a/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py b/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py index d3462444..da6cc5f4 100644 --- a/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py +++ b/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py @@ -1,20 +1,22 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT queries with -# the following options: -# -# * SNMPv1 -# * with SNMP community "public" (read access) or "private" (write access) -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 -# * using Twisted fraework for network transport -# -# The following Net-SNMP's commands will GET/SET a value at this Agent: -# -# $ snmpget -v1 -c public 127.0.0.1 SNMPv2-MIB::sysLocation.0 -# $ snmpset -v1 -c private 127.0.0.1 SNMPv2-MIB::sysLocation.0 s "far away" -# +""" +Multiple SNMP communities ++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT queries with +the following options: + +* SNMPv1 +* with SNMP community "public" (read access) or "private" (write access) +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 +* using Twisted fraework for network transport + +The following Net-SNMP commands will GET/SET a value at this Agent: + +| $ snmpget -v1 -c public 127.0.0.1 SNMPv2-MIB::sysLocation.0 +| $ snmpset -v1 -c private 127.0.0.1 SNMPv2-MIB::sysLocation.0 s "far away" + +"""# from twisted.internet import reactor from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context diff --git a/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py b/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py index 36d9d36e..91fd9557 100644 --- a/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py +++ b/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py @@ -1,23 +1,26 @@ -# -# Command Responder -# -# Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with -# the following options: -# -# * SNMPv3 -# * with USM user 'usr-md5-des', auth: MD5, priv DES or -# with USM user 'usr-sha-none', auth: SHA, no privacy -# with USM user 'usr-sha-aes128', auth: SHA, priv AES -# * allow access to SNMPv2-MIB objects (1.3.6.1.2.1) -# * over IPv4/UDP, listening at 127.0.0.1:161 -# * using Twisted framework for network transport -# -# Either of the following Net-SNMP's commands will walk this Agent: -# -# $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 -# $ snmpwalk -v3 -u usr-sha-none -l authNoPriv -a SHA -A authkey1 localhost .1.3.6 -# $ snmpwalk -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 localhost .1.3.6 -# +""" +Multiple SNMP USM users ++++++++++++++++++++++++ + +Listen and respond to SNMP GET/SET/GETNEXT/GETBULK queries with +the following options: + +* SNMPv3 +* with USM user: + * 'usr-md5-des', auth: MD5, priv DES or + * 'usr-sha-none', auth: SHA, no privacy + * 'usr-sha-aes128', auth: SHA, priv AES +* allow access to SNMPv2-MIB objects (1.3.6.1.2.1) +* over IPv4/UDP, listening at 127.0.0.1:161 +* using Twisted framework for network transport + +Either of the following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 localhost .1.3.6 +| $ snmpwalk -v3 -u usr-sha-none -l authNoPriv -a SHA -A authkey1 localhost .1.3.6 +| $ snmpwalk -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 localhost .1.3.6 + +"""# from twisted.internet import reactor from pysnmp.entity import engine, config from pysnmp.entity.rfc3413 import cmdrsp, context diff --git a/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py b/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py index 4f9b68f0..b7edf7dd 100644 --- a/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py +++ b/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py @@ -1,21 +1,24 @@ -# -# Notification Receiver -# -# Receive SNMP TRAP/INFORM messages with the following options: -# -# * SNMPv1/SNMPv2c -# * with SNMP community "public" -# * over IPv4/UDP, listening at 127.0.0.1:162 -# over IPv4/UDP, listening at 127.0.0.1:2162 -# * using Twisted framework for network transport -# * print received data on stdout -# -# Either of the following Net-SNMP's commands will send notifications to this -# receiver: -# -# $ snmptrap -v2c -c public 127.0.0.1:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test -# $ snmpinform -v2c -c public 127.0.0.1:2162 123 1.3.6.1.6.3.1.1.5.1 -# +""" +Serving multiple network interfaces ++++++++++++++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv1/SNMPv2c +* with SNMP community "public" +* listen on two local network interfaces: + * IPv4/UDP, listening at 127.0.0.1:162 + * IPv4/UDP, listening at 127.0.0.1:2162 +* using Twisted framework for network transport +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v2c -c public 127.0.0.1:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test +| $ snmpinform -v2c -c public 127.0.0.1:2162 123 1.3.6.1.6.3.1.1.5.1 + +"""# from twisted.internet import reactor from pysnmp.entity import engine, config from pysnmp.carrier.twisted.dgram import udp diff --git a/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py b/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py index 1192427c..a82bd3dd 100644 --- a/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py +++ b/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py @@ -1,24 +1,26 @@ -# -# Notification Receiver -# -# Receive SNMP TRAP/INFORM messages with the following options: -# -# * SNMPv3 -# * with USM users: -# 'usr-md5-des', auth: MD5, priv DES, ContextEngineId: 8000000001020304 -# 'usr-md5-none', auth: MD5, priv NONE, ContextEngineId: 8000000001020304 -# 'usr-sha-aes128', auth: SHA, priv AES, ContextEngineId: 8000000001020304 -# * over IPv4/UDP, listening at 127.0.0.1:162 -# * using Twisted framework for network transport -# * print received data on stdout -# -# Either of the following Net-SNMP's commands will send notifications to this -# receiver: -# -# $ snmptrap -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -e 8000000001020304 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 -# $ snmptrap -v3 -u usr-md5-none -l authNoPriv -A authkey1 -e 8000000001020304 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 -# $ snmpinform -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 -# +""" +Multiple SNMP USM users ++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv3 +* with USM users: + * 'usr-md5-des', auth: MD5, priv DES, ContextEngineId: 8000000001020304 + * 'usr-md5-none', auth: MD5, priv NONE, ContextEngineId: 8000000001020304 + * 'usr-sha-aes128', auth: SHA, priv AES, ContextEngineId: 8000000001020304 +* over IPv4/UDP, listening at 127.0.0.1:162 +* using Twisted framework for network transport +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -e 8000000001020304 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 +| $ snmptrap -v3 -u usr-md5-none -l authNoPriv -A authkey1 -e 8000000001020304 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 +| $ snmpinform -v3 -u usr-sha-aes128 -l authPriv -a SHA -A authkey1 -x AES -X privkey1 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 + +"""# from twisted.internet import reactor from pysnmp.entity import engine, config from pysnmp.carrier.twisted.dgram import udp -- cgit v1.2.1