summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2015-09-21 06:32:31 +0000
committerelie <elie>2015-09-21 06:32:31 +0000
commit66b54b016bec3312059f0add5dcc8535d2a1a6c6 (patch)
treebb2972af4148112bd56aa9444ca858f83f0bb976
parent8ede39948b4f6037012552bab20da2ff8376d715 (diff)
downloadpysnmp-66b54b016bec3312059f0add5dcc8535d2a1a6c6.tar.gz
more adjustments followed layout changes
-rw-r--r--CHANGES.txt6
-rw-r--r--docs/source/docs/contents.rst14
-rw-r--r--docs/source/docs/hlapi/asyncore/agent/ntforg/async-notification-originator.rst8
-rw-r--r--docs/source/docs/hlapi/asyncore/agent/ntforg/notification.rst8
-rw-r--r--docs/source/docs/hlapi/asyncore/manager/cmdgen/async-command-generator.rst9
-rw-r--r--docs/source/docs/hlapi/asyncore/manager/cmdgen/bulkcmd.rst8
-rw-r--r--docs/source/docs/hlapi/asyncore/manager/cmdgen/getcmd.rst8
-rw-r--r--docs/source/docs/hlapi/asyncore/manager/cmdgen/nextcmd.rst8
-rw-r--r--docs/source/docs/hlapi/asyncore/manager/cmdgen/setcmd.rst8
-rw-r--r--docs/source/docs/hlapi/security-configuration.rst39
-rw-r--r--docs/source/docs/hlapi/snmp-context.rst23
-rw-r--r--docs/source/docs/v3arch/snmp-engine.rst4
-rw-r--r--docs/source/examples/contents.rst2
-rw-r--r--docs/source/examples/hlapi/asyncore/agent/ntforg/advanced-topics.rst28
-rw-r--r--docs/source/examples/hlapi/asyncore/agent/ntforg/asynchronous-operations.rst40
-rw-r--r--docs/source/examples/hlapi/asyncore/agent/ntforg/common-notifications.rst28
-rw-r--r--docs/source/examples/hlapi/asyncore/agent/ntforg/evaluating-notification-type.rst29
-rw-r--r--docs/source/examples/hlapi/asyncore/agent/ntforg/snmp-v1-trap-variants.rst29
-rw-r--r--docs/source/examples/hlapi/asyncore/agent/ntforg/snmp-versions.rst40
-rw-r--r--docs/source/examples/hlapi/asyncore/contents.rst84
-rw-r--r--docs/source/examples/hlapi/asyncore/manager/cmdgen/advanced-topics.rst84
-rw-r--r--docs/source/examples/hlapi/asyncore/manager/cmdgen/asynchronous-operations.rst39
-rw-r--r--docs/source/examples/hlapi/asyncore/manager/cmdgen/mib-tweaks.rst48
-rw-r--r--docs/source/examples/hlapi/asyncore/manager/cmdgen/modifying-variables.rst30
-rw-r--r--docs/source/examples/hlapi/asyncore/manager/cmdgen/snmp-versions.rst72
-rw-r--r--docs/source/examples/hlapi/asyncore/manager/cmdgen/table-operations.rst50
-rw-r--r--docs/source/examples/hlapi/asyncore/manager/cmdgen/transport-tweaks.rst29
-rw-r--r--docs/source/examples/hlapi/asyncore/manager/cmdgen/walking-operations.rst51
-rw-r--r--docs/source/examples/v3arch/asyncore/contents.rst2
-rw-r--r--docs/source/quick-start.rst8
-rw-r--r--docs/source/snmp-overview.rst2
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py60
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py51
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py88
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py50
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/custom-contextname.py48
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py50
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py46
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py49
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py37
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/v3-inform.py49
-rw-r--r--examples/hlapi/asyncore/agent/ntforg/v3-trap.py45
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/async-pull-mibs-from-multiple-agents-at-once.py86
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/async-query-multiple-snmp-engines.py101
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/coerce-set-value-to-mib-spec.py39
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/custom-asn1-mib-search-path.py39
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py45
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid.py43
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/custom-pysnmp-mibs-search-path.py45
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/custom-timeout-and-retries.py53
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/custom-v3-security-name.py38
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py42
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-index.py41
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-multiple-indices.py46
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py48
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-packets.py44
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-variables.py47
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/getnext-limit-number-of-variables.py46
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py43
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-async-queries.py85
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/multiple-get-calls.py47
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/preload-pysnmp-mibs.py43
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py42
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/pull-whole-snmp-table.py53
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/query-agents-from-multuple-threads.py127
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/set-multiple-scalar-values.py49
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/specific-v3-engine-id.py86
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/usm-md5-des.py39
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/usm-md5-none.py38
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/usm-none-none.py39
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/usm-sha-aes128.py57
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/v1-get.py37
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/v2c-get.py39
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/v2c-getbulk.py46
-rw-r--r--examples/hlapi/asyncore/manager/cmdgen/waive-mib-lookup.py45
-rw-r--r--pysnmp/entity/engine.py3
-rw-r--r--pysnmp/hlapi/__init__.py5
-rw-r--r--pysnmp/hlapi/asyncore/__init__.py1
-rw-r--r--pysnmp/hlapi/asyncore/_sync/cmdgen.py8
-rw-r--r--setup.py7
80 files changed, 3122 insertions, 31 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 83a88f6..0c990ca 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -21,6 +21,12 @@ Revision 4.3.0, work in progress
* Promote the use of dedicated classes for dealing with OID-value pairs.
Instances of those classes resemble OBJECT-IDENTITY, OBJECT-TYPE and
NOTIFICATION-TYPE MIB structures.
+ * Oneliner API reworked to become more generic: its LCD configuration
+ shortcuts and and var-bindings processing code split off SNMP apps
+ classes to stand-alone objects. The whole API also moved up in package
+ naming hierarchy and becomes 'pysnmp.hlapi.asyncore' (hlapi is
+ apparently an African fish). Old oneliner API remains fully operational
+ at its original location.
* Synchronous oneliner apps redesigned to offer Python generator-based
API along with a more comprehensive set of accepted parameters.
* keep backward compatibility for all existing major/documented interfaces
diff --git a/docs/source/docs/contents.rst b/docs/source/docs/contents.rst
index ddde9cf..1e6dc2f 100644
--- a/docs/source/docs/contents.rst
+++ b/docs/source/docs/contents.rst
@@ -13,7 +13,7 @@ it will let you perform SNMP GET/SET/WALK operations by pasting code
snippets from this web-site right into your Python interactive session.
.. toctree::
- /docs/v3arch/asyncore/oneliner/contents
+ /docs/hlapi/contents
At the basic level, PySNMP offers a complete set of Standard SNMP
Applications to give you maximum flexibility with integration of SNMP
@@ -29,18 +29,6 @@ PySNMP offers native bindings to some of these framework.
.. /docs/v3arch/trollius/contents
.. /docs/v3arch/twisted/contents
-All programming interfaces mentioned above revolve around the notion
-of SNMP Engine:
-
-.. toctree::
- /docs/v3arch/snmp-engine
-
-SNMP represents the information is manages in form of values belonging to
-a set of types.
-
-.. toctree::
- /docs/snmp-data-types
-
At the other end of the complexity spectrum, PySNMP offers packet-level
ASN.1 data structures that let you build, parse and analyze SNMP messages
travelling over network. This extremely low-level programming interface is
diff --git a/docs/source/docs/hlapi/asyncore/agent/ntforg/async-notification-originator.rst b/docs/source/docs/hlapi/asyncore/agent/ntforg/async-notification-originator.rst
new file mode 100644
index 0000000..15fb19e
--- /dev/null
+++ b/docs/source/docs/hlapi/asyncore/agent/ntforg/async-notification-originator.rst
@@ -0,0 +1,8 @@
+.. toctree::
+ :maxdepth: 2
+
+Asynchronous Notification Originator
+====================================
+
+.. autoclass:: pysnmp.hlapi.asyncore.AsyncNotificationOriginator
+ :members:
diff --git a/docs/source/docs/hlapi/asyncore/agent/ntforg/notification.rst b/docs/source/docs/hlapi/asyncore/agent/ntforg/notification.rst
new file mode 100644
index 0000000..e9d55cf
--- /dev/null
+++ b/docs/source/docs/hlapi/asyncore/agent/ntforg/notification.rst
@@ -0,0 +1,8 @@
+
+TRAP/INFORM notification
+========================
+
+.. toctree::
+ :maxdepth: 2
+
+.. autofunction:: pysnmp.hlapi.asyncore.sendNotification
diff --git a/docs/source/docs/hlapi/asyncore/manager/cmdgen/async-command-generator.rst b/docs/source/docs/hlapi/asyncore/manager/cmdgen/async-command-generator.rst
new file mode 100644
index 0000000..f8584a7
--- /dev/null
+++ b/docs/source/docs/hlapi/asyncore/manager/cmdgen/async-command-generator.rst
@@ -0,0 +1,9 @@
+
+Asynchronous Command Generator
+==============================
+
+.. toctree::
+ :maxdepth: 2
+
+.. autoclass:: pysnmp.hlapi.asyncore.AsyncCommandGenerator
+ :members:
diff --git a/docs/source/docs/hlapi/asyncore/manager/cmdgen/bulkcmd.rst b/docs/source/docs/hlapi/asyncore/manager/cmdgen/bulkcmd.rst
new file mode 100644
index 0000000..59bee11
--- /dev/null
+++ b/docs/source/docs/hlapi/asyncore/manager/cmdgen/bulkcmd.rst
@@ -0,0 +1,8 @@
+
+GETBULK command
+===============
+
+.. toctree::
+ :maxdepth: 2
+
+.. autofunction:: pysnmp.hlapi.asyncore.bulkCmd
diff --git a/docs/source/docs/hlapi/asyncore/manager/cmdgen/getcmd.rst b/docs/source/docs/hlapi/asyncore/manager/cmdgen/getcmd.rst
new file mode 100644
index 0000000..c224491
--- /dev/null
+++ b/docs/source/docs/hlapi/asyncore/manager/cmdgen/getcmd.rst
@@ -0,0 +1,8 @@
+
+GET command
+===========
+
+.. toctree::
+ :maxdepth: 2
+
+.. autofunction:: pysnmp.hlapi.asyncore.getCmd
diff --git a/docs/source/docs/hlapi/asyncore/manager/cmdgen/nextcmd.rst b/docs/source/docs/hlapi/asyncore/manager/cmdgen/nextcmd.rst
new file mode 100644
index 0000000..1a8856a
--- /dev/null
+++ b/docs/source/docs/hlapi/asyncore/manager/cmdgen/nextcmd.rst
@@ -0,0 +1,8 @@
+
+GETNEXT command
+===============
+
+.. toctree::
+ :maxdepth: 2
+
+.. autofunction:: pysnmp.hlapi.asyncore.nextCmd
diff --git a/docs/source/docs/hlapi/asyncore/manager/cmdgen/setcmd.rst b/docs/source/docs/hlapi/asyncore/manager/cmdgen/setcmd.rst
new file mode 100644
index 0000000..92f6c91
--- /dev/null
+++ b/docs/source/docs/hlapi/asyncore/manager/cmdgen/setcmd.rst
@@ -0,0 +1,8 @@
+
+SET command
+===========
+
+.. toctree::
+ :maxdepth: 2
+
+.. autofunction:: pysnmp.hlapi.asyncore.setCmd
diff --git a/docs/source/docs/hlapi/security-configuration.rst b/docs/source/docs/hlapi/security-configuration.rst
new file mode 100644
index 0000000..a5b812c
--- /dev/null
+++ b/docs/source/docs/hlapi/security-configuration.rst
@@ -0,0 +1,39 @@
+
+Security Parameters
+===================
+
+Calls to high-level Applications API consume Security Parameters
+configuration object on input. The shortcut classes described in
+this section convey configuration information to SNMP engine's
+Local Configuration Datastore (:RFC:`2271#section-3.4.2`).
+Once committed to LCD, SNMP engine saves its configuration for
+the lifetime of SNMP engine object.
+
+Security Parameters object is Security Model specific.
+:py:class:`~pysnmp.hlapi.UsmUserData` class
+serves SNMPv3 User-Based Security Model configuration, while
+:py:class:`~pysnmp.hlapi.CommunityData`
+class is used for Community-Based Security Model of SNMPv1/SNMPv2c.
+
+.. toctree::
+ :maxdepth: 2
+
+.. autoclass:: pysnmp.hlapi.CommunityData(communityIndex, communityName=None, mpModel=1, contextEngineId=None, contextName='', tag='')
+
+.. autoclass:: pysnmp.hlapi.UsmUserData(userName, authKey=None, privKey=None, authProtocol=usmNoAuthProtocol, privProtocol=usmNoPrivProtocol, securityEngineId=None)
+
+Identification of Authentication and Privacy Protocols is done
+via constant OIDs:
+
+.. autodata:: pysnmp.hlapi.usmNoAuthProtocol
+.. autodata:: pysnmp.hlapi.usmHMACMD5AuthProtocol
+.. autodata:: pysnmp.hlapi.usmHMACSHAAuthProtocol
+
+.. autodata:: pysnmp.hlapi.usmNoPrivProtocol
+.. autodata:: pysnmp.hlapi.usmDESPrivProtocol
+.. autodata:: pysnmp.hlapi.usm3DESEDEPrivProtocol
+.. autodata:: pysnmp.hlapi.usmAesCfb128Protocol
+.. autodata:: pysnmp.hlapi.usmAesCfb192Protocol
+.. autodata:: pysnmp.hlapi.usmAesCfb256Protocol
+
+
diff --git a/docs/source/docs/hlapi/snmp-context.rst b/docs/source/docs/hlapi/snmp-context.rst
new file mode 100644
index 0000000..d29484e
--- /dev/null
+++ b/docs/source/docs/hlapi/snmp-context.rst
@@ -0,0 +1,23 @@
+
+SNMP Context
+============
+
+Calls to high-level Applications API consume SNMP Context
+configuration object on input. The shortcut class described in
+this section convey this MIB instance identification information
+to SNMP PDU for further communication to peer SNMP engine
+(:RFC:`3411#section-4.1`).
+
+.. note::
+
+ SNMP context is only defined within SNMPv3 framework. For SNMPv1/v2c
+ architecture integration :RFC:`2576#section-5.1` introduces
+ interoperability aid which is available through
+ :py:class:`~pysnmp.hlapi.CommunityData`.
+
+
+.. toctree::
+ :maxdepth: 2
+
+.. autoclass:: pysnmp.hlapi.ContextData
+
diff --git a/docs/source/docs/v3arch/snmp-engine.rst b/docs/source/docs/v3arch/snmp-engine.rst
index 339d618..f72c737 100644
--- a/docs/source/docs/v3arch/snmp-engine.rst
+++ b/docs/source/docs/v3arch/snmp-engine.rst
@@ -3,11 +3,11 @@ SNMP Engine
===========
SNMP Engine is a central, stateful object used by all SNMP v3
-substsems. Calls to oneliner Applications API also consume SNMP
+substsems. Calls to high-level Applications API also consume SNMP
Engine object on input.
.. toctree::
:maxdepth: 2
-.. autoclass:: pysnmp.entity.engine.SnmpEngine(snmpEngineID=None)
+.. autoclass:: pysnmp.hlapi.asyncore.SnmpEngine(snmpEngineID=None)
diff --git a/docs/source/examples/contents.rst b/docs/source/examples/contents.rst
index eabdafe..a93af0f 100644
--- a/docs/source/examples/contents.rst
+++ b/docs/source/examples/contents.rst
@@ -18,7 +18,7 @@ APIs are:
.. toctree::
:maxdepth: 2
- /examples/v3arch/asyncore/oneliner/contents
+ /examples/hlapi/asyncore/contents
#. Complete implementation of all official Standard SNMP Applications. It
should let you implement any SNMP operation defined in the standard.
diff --git a/docs/source/examples/hlapi/asyncore/agent/ntforg/advanced-topics.rst b/docs/source/examples/hlapi/asyncore/agent/ntforg/advanced-topics.rst
new file mode 100644
index 0000000..06eb06b
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/agent/ntforg/advanced-topics.rst
@@ -0,0 +1,28 @@
+.. toctree::
+ :maxdepth: 2
+
+Advanced topic
+--------------
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/custom-contextname.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/custom-contextname.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/custom-contextname.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py>` script.
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/agent/ntforg/asynchronous-operations.rst b/docs/source/examples/hlapi/asyncore/agent/ntforg/asynchronous-operations.rst
new file mode 100644
index 0000000..0ff429a
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/agent/ntforg/asynchronous-operations.rst
@@ -0,0 +1,40 @@
+.. toctree::
+ :maxdepth: 2
+
+Asynchronous operations
+-----------------------
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py>` script.
+
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/agent/ntforg/common-notifications.rst b/docs/source/examples/hlapi/asyncore/agent/ntforg/common-notifications.rst
new file mode 100644
index 0000000..b8048e1
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/agent/ntforg/common-notifications.rst
@@ -0,0 +1,28 @@
+.. toctree::
+ :maxdepth: 2
+
+Common notifications
+--------------------
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/v3-inform.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/v3-inform.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/v3-inform.py>` script.
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/agent/ntforg/evaluating-notification-type.rst b/docs/source/examples/hlapi/asyncore/agent/ntforg/evaluating-notification-type.rst
new file mode 100644
index 0000000..e06b7ff
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/agent/ntforg/evaluating-notification-type.rst
@@ -0,0 +1,29 @@
+.. toctree::
+ :maxdepth: 2
+
+Evaluating NOTIFICATION-TYPE
+----------------------------
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py>` script.
+
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/agent/ntforg/snmp-v1-trap-variants.rst b/docs/source/examples/hlapi/asyncore/agent/ntforg/snmp-v1-trap-variants.rst
new file mode 100644
index 0000000..7327867
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/agent/ntforg/snmp-v1-trap-variants.rst
@@ -0,0 +1,29 @@
+.. toctree::
+ :maxdepth: 2
+
+SNMPv1 TRAP variants
+--------------------
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py>` script.
+
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/agent/ntforg/snmp-versions.rst b/docs/source/examples/hlapi/asyncore/agent/ntforg/snmp-versions.rst
new file mode 100644
index 0000000..e861b49
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/agent/ntforg/snmp-versions.rst
@@ -0,0 +1,40 @@
+.. toctree::
+ :maxdepth: 2
+
+Various SNMP versions
+----------------------
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/v3-trap.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/v3-trap.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/v3-trap.py>` script.
+
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/contents.rst b/docs/source/examples/hlapi/asyncore/contents.rst
new file mode 100644
index 0000000..d510551
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/contents.rst
@@ -0,0 +1,84 @@
+
+High-level SNMP
+===============
+
+This chapter illustrates various uses of the high-level programming
+interfaces to some of Standard SNMP Applicaitons, as defined in
+`RFC3413 <https://tools.ietf.org/html/rfc3413>`_.
+The so called high-level API (hlapi) is designed to be simple, concise and
+suitable for the most frequent operations. For that matter only
+Command Generator and Notification Originator Applications are currently
+wrapped into a nearly one-line Python expression.
+
+.. note:: The following examples involve creating Python iterator,
+ the next() call is used to invoke iterator just once.
+
+In most examples approximate analogues of well known Net-SNMP snmp* tools
+command line options are shown. That may help those readers who, by chance
+are familiar with Net-SNMP tools, better understanding what example code doe
+
+Command Generator Applications
+------------------------------
+
+Here's a quick example on a simple SNMP GET by high-level API:
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/v1-get.py
+ :start-after: options:
+ :end-before: Functionally
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/v1-get.py
+ :start-after: """#
+ :language: python
+
+To make use of SNMPv3 and USM, the following code performs a series of
+SNMP GETNEXT operations effectively fetching a table of SNMP variables
+from SNMP Agent:
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py
+ :start-after: options:
+ :end-before: Functionally
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py
+ :start-after: """#
+ :language: python
+
+More examples on Command Generator API usage follow.
+
+.. toctree::
+
+ /examples/hlapi/asyncore/manager/cmdgen/snmp-versions
+ /examples/hlapi/asyncore/manager/cmdgen/modifying-variables
+ /examples/hlapi/asyncore/manager/cmdgen/walking-operations
+ /examples/hlapi/asyncore/manager/cmdgen/table-operations
+ /examples/hlapi/asyncore/manager/cmdgen/mib-tweaks
+ /examples/hlapi/asyncore/manager/cmdgen/transport-tweaks
+ /examples/hlapi/asyncore/manager/cmdgen/asynchronous-operations
+ /examples/hlapi/asyncore/manager/cmdgen/advanced-topics
+
+Notification Originator Application
+-----------------------------------
+
+Sending SNMP TRAP's and INFORM's is as easy with PySNMP library.
+The following code sends SNMP TRAP:
+
+.. include:: /../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py
+ :start-after: options:
+ :end-before: Functionally
+
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py
+ :start-after: """#
+ :language: python
+
+More examples on Notification Originator API usage follow.
+
+.. toctree::
+
+ /examples/hlapi/asyncore/agent/ntforg/snmp-versions
+ /examples/hlapi/asyncore/agent/ntforg/common-notifications
+ /examples/hlapi/asyncore/agent/ntforg/snmp-v1-trap-variants
+ /examples/hlapi/asyncore/agent/ntforg/evaluating-notification-type
+ /examples/hlapi/asyncore/agent/ntforg/asynchronous-operations
+ /examples/hlapi/asyncore/agent/ntforg/advanced-topics
+
+More sophisticated or less popular SNMP operations can still be performed
+with PySNMP through its Native API to Standard SNMP Applications.
diff --git a/docs/source/examples/hlapi/asyncore/manager/cmdgen/advanced-topics.rst b/docs/source/examples/hlapi/asyncore/manager/cmdgen/advanced-topics.rst
new file mode 100644
index 0000000..969d6ed
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/manager/cmdgen/advanced-topics.rst
@@ -0,0 +1,84 @@
+.. toctree::
+ :maxdepth: 2
+
+Advanced topics
+---------------
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-packets.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-packets.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-packets.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/multiple-get-calls.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/multiple-get-calls.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/multiple-get-calls.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-v3-security-name.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-v3-security-name.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/custom-v3-security-name.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/specific-v3-engine-id.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/specific-v3-engine-id.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/specific-v3-engine-id.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/query-agents-from-multuple-threads.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/query-agents-from-multuple-threads.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/query-agents-from-multuple-threads.py>` script.
+
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/manager/cmdgen/asynchronous-operations.rst b/docs/source/examples/hlapi/asyncore/manager/cmdgen/asynchronous-operations.rst
new file mode 100644
index 0000000..0236a96
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/manager/cmdgen/asynchronous-operations.rst
@@ -0,0 +1,39 @@
+.. toctree::
+ :maxdepth: 2
+
+Asynchronous operations
+-----------------------
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-async-queries.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-async-queries.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-async-queries.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/async-query-multiple-snmp-engines.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/async-query-multiple-snmp-engines.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/async-query-multiple-snmp-engines.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/async-pull-mibs-from-multiple-agents-at-once.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/async-pull-mibs-from-multiple-agents-at-once.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/async-pull-mibs-from-multiple-agents-at-once.py>` script.
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/manager/cmdgen/mib-tweaks.rst b/docs/source/examples/hlapi/asyncore/manager/cmdgen/mib-tweaks.rst
new file mode 100644
index 0000000..168eb69
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/manager/cmdgen/mib-tweaks.rst
@@ -0,0 +1,48 @@
+.. toctree::
+ :maxdepth: 2
+
+MIB tweaks
+----------
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/waive-mib-lookup.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/waive-mib-lookup.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/waive-mib-lookup.py>` script.
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/preload-pysnmp-mibs.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/preload-pysnmp-mibs.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/preload-pysnmp-mibs.py>` script.
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-asn1-mib-search-path.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-asn1-mib-search-path.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/custom-asn1-mib-search-path.py>` script.
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-pysnmp-mibs-search-path.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-pysnmp-mibs-search-path.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/custom-pysnmp-mibs-search-path.py>` script.
+
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/manager/cmdgen/modifying-variables.rst b/docs/source/examples/hlapi/asyncore/manager/cmdgen/modifying-variables.rst
new file mode 100644
index 0000000..0fdf8dc
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/manager/cmdgen/modifying-variables.rst
@@ -0,0 +1,30 @@
+
+.. toctree::
+ :maxdepth: 2
+
+Modifying values
+----------------
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/coerce-set-value-to-mib-spec.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/coerce-set-value-to-mib-spec.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/coerce-set-value-to-mib-spec.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/set-multiple-scalar-values.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/set-multiple-scalar-values.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/set-multiple-scalar-values.py>` script.
+
+
+See also: :doc:`library-reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/manager/cmdgen/snmp-versions.rst b/docs/source/examples/hlapi/asyncore/manager/cmdgen/snmp-versions.rst
new file mode 100644
index 0000000..ad786db
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/manager/cmdgen/snmp-versions.rst
@@ -0,0 +1,72 @@
+.. toctree::
+ :maxdepth: 2
+
+Various SNMP versions
+----------------------
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/v1-get.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/v1-get.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/v1-get.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/v2c-get.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/v2c-get.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/v2c-get.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/usm-md5-des.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/usm-md5-des.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/usm-md5-des.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/usm-md5-none.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/usm-md5-none.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/usm-md5-none.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/usm-none-none.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/usm-none-none.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/usm-none-none.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/usm-sha-aes128.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/usm-sha-aes128.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/usm-sha-aes128.py>` script.
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/manager/cmdgen/table-operations.rst b/docs/source/examples/hlapi/asyncore/manager/cmdgen/table-operations.rst
new file mode 100644
index 0000000..9ea83c0
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/manager/cmdgen/table-operations.rst
@@ -0,0 +1,50 @@
+.. toctree::
+ :maxdepth: 2
+
+Table operations
+----------------
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-index.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-index.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-index.py>` script.
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-multiple-indices.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-multiple-indices.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-multiple-indices.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-whole-snmp-table.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-whole-snmp-table.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/pull-whole-snmp-table.py>` script.
+
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/manager/cmdgen/transport-tweaks.rst b/docs/source/examples/hlapi/asyncore/manager/cmdgen/transport-tweaks.rst
new file mode 100644
index 0000000..e5f754c
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/manager/cmdgen/transport-tweaks.rst
@@ -0,0 +1,29 @@
+.. toctree::
+ :maxdepth: 2
+
+Transport tweaks
+----------------
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-timeout-and-retries.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/custom-timeout-and-retries.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/custom-timeout-and-retries.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py>` script.
+
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/hlapi/asyncore/manager/cmdgen/walking-operations.rst b/docs/source/examples/hlapi/asyncore/manager/cmdgen/walking-operations.rst
new file mode 100644
index 0000000..1d5b315
--- /dev/null
+++ b/docs/source/examples/hlapi/asyncore/manager/cmdgen/walking-operations.rst
@@ -0,0 +1,51 @@
+.. toctree::
+ :maxdepth: 2
+
+Walking operations
+------------------
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-variables.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-variables.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-variables.py>` script.
+
+
+.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/getnext-limit-number-of-variables.py
+ :start-after: """
+ :end-before: """#
+
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/getnext-limit-number-of-variables.py
+ :start-after: """#
+ :language: python
+
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/getnext-limit-number-of-variables.py>` script.
+
+
+See also: :doc:`library reference </docs/contents>`.
diff --git a/docs/source/examples/v3arch/asyncore/contents.rst b/docs/source/examples/v3arch/asyncore/contents.rst
index 3b1295b..d5cdc9b 100644
--- a/docs/source/examples/v3arch/asyncore/contents.rst
+++ b/docs/source/examples/v3arch/asyncore/contents.rst
@@ -3,7 +3,7 @@ SNMP with Asyncore
==================
If you find yourself unable to use particular SNMP feature with the
-high-level, "oneliner" API, your next step would be to use SNMPv3
+high-level (hlapi) API, your next step would be to use SNMPv3
engine services through one of the Standard SNMP Applications
(`RFC3413 <https://tools.ietf.org/html/rfc3413>`_).
diff --git a/docs/source/quick-start.rst b/docs/source/quick-start.rst
index b0e5b4e..9e14c03 100644
--- a/docs/source/quick-start.rst
+++ b/docs/source/quick-start.rst
@@ -17,11 +17,11 @@ So just cut&paste the following code right into your Python prompt. The
code will performs SNMP GET operation for a sysDescr.0 object at a
publically available SNMP Agent at **demo.snmplabs.com**:
-.. literalinclude:: /../../examples/v3arch/asyncore/oneliner/manager/cmdgen/v1-get.py
+.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/v1-get.py
:start-after: """#
:language: python
-:download:`Download</../../examples/v3arch/asyncore/oneliner/manager/cmdgen/v1-get.py>` script.
+:download:`Download</../../examples/hlapi/asyncore/manager/cmdgen/v1-get.py>` script.
If everything works as it should you will get:
@@ -39,11 +39,11 @@ Send SNMP TRAP
To send a trivial TRAP message to your local Notification Receiver
just cut&paste the following code into your interactive Python session:
-.. literalinclude:: /../../examples/v3arch/asyncore/oneliner/agent/ntforg/default-v1-trap.py
+.. literalinclude:: /../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py
:start-after: """#
:language: python
-:download:`Download</../../examples/v3arch/asyncore/oneliner/agent/ntforg/default-v1-trap.py>` script.
+:download:`Download</../../examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py>` script.
For more sophisticated examples and use cases please refer to
:doc:`examples <examples/contents>` and :doc:`library reference <docs/contents>`
diff --git a/docs/source/snmp-overview.rst b/docs/source/snmp-overview.rst
index b532f66..985cd79 100644
--- a/docs/source/snmp-overview.rst
+++ b/docs/source/snmp-overview.rst
@@ -306,7 +306,7 @@ linked objects at runtime. So here are the main components:
kept in LCD. LCD Configurator is a wrapper aimed at simplifying LCD
operations.
-In most cases user is expected to only deal with the high-level, oneliner
+In most cases user is expected to only deal with the high-level
API to all these PySNMP components. However implementing SNMP Agents,
Proxies and some other fine features of Managers require using the Standard
Applications API. In those cases general understanding of SNMP operations
diff --git a/examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py b/examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py
new file mode 100644
index 0000000..d14380b
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py
@@ -0,0 +1,60 @@
+"""
+Multiple concurrent notifications
++++++++++++++++++++++++++++++++++
+
+Send multiple SNMP notifications at once using the following options:
+
+* SNMPv2c and SNMPv3
+* with community name 'public' or USM username usr-md5-des
+* over IPv4/UDP
+* send INFORM notification
+* to multiple Managers
+* with TRAP ID 'coldStart' specified as a MIB symbol
+* include managed object information specified as var-bind objects pair
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+# List of targets in the followin format:
+# ( ( authData, transportTarget ), ... )
+targets = (
+ # 1-st target (SNMPv2c over IPv4/UDP)
+ ( CommunityData('public'),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData() ),
+ # 2-nd target (SNMPv3 over IPv4/UDP)
+ ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData() ),
+)
+
+def cbFun(snmpEngine, sendRequestHandle, errorIndication,
+ errorStatus, errorIndex, varBinds, cbctx):
+ if errorIndication:
+ print('Notification %s not sent: %s' % (sendRequestHandle, errorIndication))
+ elif errorStatus:
+ print('Notification Receiver returned error for %s: %s @%s' %
+ (sendRequestHandle, errorStatus, errorIndex))
+ else:
+ print('Notification %s delivered:' % sendRequestHandle)
+ for name, val in varBinds:
+ print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+
+snmpEngine = engine.SnmpEngine()
+
+ntfOrg = AsyncNotificationOriginator()
+
+for authData, transportTarget, contextData in targets:
+ sendPduHandle = ntfOrg.sendNotification(
+ snmpEngine,
+ authData,
+ transportTarget,
+ contextData,
+ 'inform', # NotifyType
+ NotificationType(
+ ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ),
+ cbInfo=(cbFun, None)
+ )
+
+snmpEngine.transportDispatcher.runDispatcher()
diff --git a/examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py b/examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py
new file mode 100644
index 0000000..3d4d4b6
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py
@@ -0,0 +1,51 @@
+"""
+Multiple concurrent queries
++++++++++++++++++++++++++++
+
+Send a bunch of different SNMP Notifications to different peers all at once,
+wait for responses asynchronously:
+
+* SNMPv1 and SNMPv2c
+* with community name 'public'
+* over IPv4/UDP
+* send TRAP notification
+* to multiple Managers
+* with TRAP ID 'coldStart' specified as a MIB symbol
+* include managed object information specified as var-bind objects pair
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+# List of targets in the followin format:
+# ( ( authData, transportTarget ), ... )
+targets = (
+ # 1-st target (SNMPv1 over IPv4/UDP)
+ ( CommunityData('public', mpModel=0),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData() ),
+ # 2-nd target (SNMPv2c over IPv4/UDP)
+ ( CommunityData('public'),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData() ),
+)
+
+snmpEngine = SnmpEngine()
+
+ntfOrg = AsyncNotificationOriginator()
+
+for authData, transportTarget, contextData in targets:
+ ntfOrg.sendNotification(
+ snmpEngine,
+ authData,
+ transportTarget,
+ contextData,
+ 'trap', # NotifyType
+ NotificationType(
+ ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ ).addVarBinds(
+ ( ObjectName('1.3.6.1.2.1.1.1.0'),
+ OctetString('my name') )
+ )
+ )
+
+snmpEngine.transportDispatcher.runDispatcher()
diff --git a/examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py b/examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py
new file mode 100644
index 0000000..7028d84
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py
@@ -0,0 +1,88 @@
+"""
+Multiple SNMP Engines
++++++++++++++++++++++
+
+Send SNMP notifications in behalf of multiple independend SNMP engines
+using the following options:
+
+* with a single transport dispatcher and two independent SNMP engines
+* SNMPv2c and SNMPv3
+* with community name 'public' or USM username usr-md5-des
+* over IPv4/UDP
+* send IMFORM notification
+* to multiple Managers
+* with TRAP ID 'coldStart' specified as a MIB symbol
+* include managed object information specified as var-bind objects pair
+
+Within this script we have a single asynchronous TransportDispatcher
+and a single UDP-based transport serving two independent SNMP engines.
+We use a single instance of AsyncNotificationOriginator with each of
+SNMP Engines to communicate INFORM notification to remote systems.
+
+When we receive a [response] message from remote system we use
+a custom message router to choose what of the two SNMP engines
+data packet should be handed over. The selection criteria we
+employ here is based on peer's UDP port number. Other selection
+criterias are also possible.
+
+"""#
+from pysnmp.hlapi.asyncore import *
+from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher
+
+# List of targets in the following format:
+# ( ( authData, transportTarget ), ... )
+targets = (
+ # 1-st target (SNMPv2c over IPv4/UDP)
+ ( CommunityData('public'),
+ UdpTransportTarget(('localhost', 1162)),
+ ContextData() ),
+ # 2-nd target (SNMPv3 over IPv4/UDP)
+ ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData() ),
+)
+
+def cbFun(snmpEngine, sendRequestHandle, errorIndication,
+ errorStatus, errorIndex, varBinds, cbCtx):
+ snmpEngine = cbCtx
+ if errorIndication:
+ print('Notification %s for %s not sent: %s' % (sendRequestHandle, snmpEngine.snmpEngineID.prettyPrint(), errorIndication))
+ elif errorStatus:
+ print('Notification Receiver returned error for request %s, SNMP Engine %s: %s @%s' % (sendRequestHandle, snmpEngine.snmpEngineID.prettyPrint(), errorStatus, errorIndex))
+ else:
+ print('Notification %s for SNMP Engine %s delivered:' % (sendRequestHandle, snmpEngine.snmpEngineID.prettyPrint()))
+ for name, val in varBinds:
+ print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+
+# Instantiate the single transport dispatcher object
+transportDispatcher = AsyncoreDispatcher()
+
+# Setup a custom data routing function to select snmpEngine by transportDomain
+transportDispatcher.registerRoutingCbFun(
+ lambda td,ta,d: ta[1] % 3 and 'A' or 'B'
+)
+
+snmpEngineA = engine.SnmpEngine()
+snmpEngineA.registerTransportDispatcher(transportDispatcher, 'A')
+
+snmpEngineB = engine.SnmpEngine()
+snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B')
+
+ntfOrg = AsyncNotificationOriginator()
+
+for authData, transportTarget, contextData in targets:
+ snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \
+ snmpEngineA or snmpEngineB
+ sendPduHandle = ntfOrg.sendNotification(
+ snmpEngine,
+ authData,
+ transportTarget,
+ contextData,
+ 'inform', # NotifyType
+ NotificationType(
+ ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ),
+ cbInfo=(cbFun, snmpEngine)
+ )
+
+transportDispatcher.runDispatcher()
diff --git a/examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py b/examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py
new file mode 100644
index 0000000..1a65a61
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py
@@ -0,0 +1,50 @@
+"""
+INFORM with custom ContextEngineId
+++++++++++++++++++++++++++++++++++
+
+Send SNMP notification using the following options:
+
+* SNMPv3
+* with user 'usr-md5-none', MD5 auth, no priv
+* send INFORM notification
+* in behalf of contextEngineId 0x8000000004030201, contextName ''
+* over IPv4/UDP
+* with TRAP ID 'warmStart' specified as a string OID
+
+Sending SNMPv3 Notification in behalf of non-default ContextEngineId
+requires having a collection of Managed Objects registered under
+the ContextEngineId being used.
+
+Functionally similar to:
+
+| $ snmpinform -v3 -l authNoPriv -u usr-md5-none -A authkey1 \
+| -E 0x8000000004030201
+| demo.snmplabs.com \
+| 12345 \
+| 1.3.6.1.6.3.1.1.5.2
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ sendNotification(SnmpEngine(),
+ UsmUserData('usr-md5-none', 'authkey1'),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData(
+ rfc1902.OctetString(hexValue='8000000004030201')
+ ),
+ 'inform',
+ NotificationType(ObjectIdentity('1.3.6.1.6.3.1.1.5.2')))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/agent/ntforg/custom-contextname.py b/examples/hlapi/asyncore/agent/ntforg/custom-contextname.py
new file mode 100644
index 0000000..c322d55
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/custom-contextname.py
@@ -0,0 +1,48 @@
+"""
+INFORM with custom ContextName
+++++++++++++++++++++++++++++++
+
+Send SNMP notification using the following options:
+
+* SNMPv3
+* with user 'usr-md5-none', MD5 auth, no priv
+* send INFORM notification
+* in behalf of contextEngineId = SnmpEngineId, contextName 'my-context'
+* over IPv4/UDP
+* with TRAP ID 'warmStart' specified as a string OID
+
+Sending SNMPv3 Notification in behalf of non-default ContextName
+requires having a collection of Managed Objects registered under
+the ContextName being used.
+
+Functionally similar to:
+
+| $ snmpinform -v3 -l authNoPriv -u usr-md5-none -A authkey1 \
+| -n my-context \
+| demo.snmplabs.com \
+| 12345 \
+| 1.3.6.1.6.3.1.1.5.2
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ sendNotification(SnmpEngine(),
+ UsmUserData('usr-md5-none', 'authkey1'),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData(contextName='my-context'),
+ 'inform',
+ NotificationType(ObjectIdentity('1.3.6.1.6.3.1.1.5.2')))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py b/examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py
new file mode 100644
index 0000000..51bf05a
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py
@@ -0,0 +1,50 @@
+"""
+Custom SNMPv1 TRAP
+++++++++++++++++++
+
+Send SNMPv1 TRAP through unified SNMPv3 message processing framework.
+
+Original v1 TRAP fields are mapped into dedicated variable-bindings,
+(see `RFC2576 <https://www.ietf.org/rfc/rfc2576.txt>`_) for details.
+
+* SNMPv1
+* with community name 'public'
+* over IPv4/UDP
+* send TRAP notification
+* with Generic Trap #6 (enterpriseSpecific) and Specific Trap 432
+* 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 demo.snmplabs.com \
+| 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.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ sendNotification(SnmpEngine(),
+ CommunityData('public', mpModel=0),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData(),
+ 'trap',
+ NotificationType(
+ ObjectIdentity('1.3.6.1.4.1.20408.4.1.1.2.0.432'),
+ ).addVarBinds(
+ ('1.3.6.1.2.1.1.3.0', 12345),
+ ('1.3.6.1.6.3.18.1.3.0', '127.0.0.1'),
+ ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'),
+ ('1.3.6.1.2.1.1.1.0', rfc1902.OctetString('my system'))
+ )
+ )
+)
+if errorIndication:
+ print(errorIndication)
diff --git a/examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py b/examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py
new file mode 100644
index 0000000..75542ba
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py
@@ -0,0 +1,46 @@
+"""
+SNMPv1 TRAP with defaults
++++++++++++++++++++++++++
+
+Send SNMPv1 TRAP through unified SNMPv3 message processing framework
+using the following options:
+
+* SNMPv1
+* with community name 'public'
+* over IPv4/UDP
+* send TRAP notification
+* with Generic Trap #1 (warmStart) and Specific Trap 0
+* with default Uptime
+* with default Agent Address
+* with Enterprise OID 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 demo.snmplabs.com \
+| 1.3.6.1.4.1.20408.4.1.1.2 \
+| 0.0.0.0 \
+| 1 \
+| 0 \
+| 0
+| '1.3.6.1.2.1.1.1.0' s 'my system'
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ sendNotification(SnmpEngine(),
+ CommunityData('public', mpModel=0),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData(),
+ 'trap',
+ NotificationType(
+ ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
+ ).addVarBinds(
+ ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'),
+ ('1.3.6.1.2.1.1.1.0', rfc1902.OctetString('my system'))
+ )
+ )
+)
+if errorIndication:
+ print(errorIndication)
diff --git a/examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py b/examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py
new file mode 100644
index 0000000..096eb34
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py
@@ -0,0 +1,49 @@
+"""
+Sending additional var-binds
+++++++++++++++++++++++++++++
+
+Send SNMP notification using the following options:
+
+* SNMPv2c
+* with community name 'public'
+* over IPv4/UDP
+* send INFORM notification
+* with TRAP ID 'coldStart' specified as a MIB symbol
+* include managed object information specified as a MIB symbol
+
+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 'my system'
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ sendNotification(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData(),
+ 'inform',
+ NotificationType(
+ ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ ).addVarBinds(
+ ObjectType(ObjectIdentity('SNMPv2-MIB','sysName',0),
+ 'my system')
+ ))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py b/examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py
new file mode 100644
index 0000000..296aebc
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py
@@ -0,0 +1,37 @@
+"""
+SNMPv2c TRAP via NOTIFICATION-TYPE
+++++++++++++++++++++++++++++++++++
+
+Initialize TRAP message contents from variables specified
+in *NOTIFICATION-TYPE* SMI macro.
+
+* SNMPv2c
+* with community name 'public'
+* over IPv4/UDP
+* send TRAP notification
+* with TRAP ID 'coldStart' specified as a MIB symbol
+* include managed object information specified as a MIB symbol
+
+Functionally similar to:
+
+| $ snmptrap -v2c -c public demo.snmplabs.com \
+| 12345
+| 1.3.6.1.4.1.20408.4.1.1.2 \
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ sendNotification(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData(),
+ 'trap',
+ NotificationType(
+ ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ )
+ )
+)
+
+if errorIndication:
+ print(errorIndication)
diff --git a/examples/hlapi/asyncore/agent/ntforg/v3-inform.py b/examples/hlapi/asyncore/agent/ntforg/v3-inform.py
new file mode 100644
index 0000000..ebf2fdf
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/v3-inform.py
@@ -0,0 +1,49 @@
+"""
+INFORM, auth: MD5 privacy: DES
+++++++++++++++++++++++++++++++
+
+Send SNMP INFORM notification using the following options:
+
+* SNMPv3
+* with user 'usr-md5-des', auth: MD5, priv DES
+* over IPv4/UDP
+* send INFORM notification
+* with TRAP ID 'warmStart' specified as a string OID
+* include managed object information 1.3.6.1.2.1.1.5.0 = 'system name'
+
+Functionally similar to:
+
+| $ snmpinform -v3 -l authPriv -u usr-sha-aes -A authkey1 -X privkey1 \
+| demo.snmplabs.com \
+| 12345 \
+| 1.3.6.1.4.1.20408.4.1.1.2 \
+| '1.3.6.1.2.1.1.1.0' s 'my system'
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ sendNotification(SnmpEngine(),
+ UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData(),
+ 'inform',
+ NotificationType(
+ ObjectIdentity('1.3.6.1.6.3.1.1.5.2')
+ ).addVarBinds(
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.5.0'),
+ 'system name')
+ ))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/agent/ntforg/v3-trap.py b/examples/hlapi/asyncore/agent/ntforg/v3-trap.py
new file mode 100644
index 0000000..27d081d
--- /dev/null
+++ b/examples/hlapi/asyncore/agent/ntforg/v3-trap.py
@@ -0,0 +1,45 @@
+"""
+SNMPv3 TRAP: auth SHA, privacy: AES128
+++++++++++++++++++++++++++++++++++++++
+
+Send SNMP notification using the following options:
+
+* SNMPv3
+* with local snmpEngineId = 0x8000000001020304 (must configure at Receiver)
+* with user 'usr-sha-aes128', auth: SHA, priv: AES128
+* over IPv4/UDP
+* send TRAP notification
+* with TRAP ID 'authenticationFailure' specified as a MIB symbol
+* do not include any additional managed object information
+
+SNMPv3 TRAPs requires pre-sharing the Notification Originator's
+value of SnmpEngineId with Notification Receiver. To facilitate that
+we will use static (e.g. not autogenerated) version of snmpEngineId.
+
+Functionally similar to:
+
+| $ snmptrap -v3 -l authPriv -u usr-sha-aes -A authkey1 -X privkey1 \
+| -a SHA -x AES \
+| demo.snmplabs.com \
+| 12345 \
+| 1.3.6.1.4.1.20408.4.1.1.2 \
+| '1.3.6.1.2.1.1.1.0' s 'my system'
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ sendNotification(SnmpEngine(OctetString(hexValue='8000000001020304')),
+ UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1',
+ authProtocol=usmHMACSHAAuthProtocol,
+ privProtocol=usmAesCfb128Protocol),
+ UdpTransportTarget(('localhost', 162)),
+ ContextData(),
+ 'trap',
+ NotificationType(
+ ObjectIdentity('SNMPv2-MIB', 'authenticationFailure')
+ )
+ )
+)
+if errorIndication:
+ print(errorIndication)
diff --git a/examples/hlapi/asyncore/manager/cmdgen/async-pull-mibs-from-multiple-agents-at-once.py b/examples/hlapi/asyncore/manager/cmdgen/async-pull-mibs-from-multiple-agents-at-once.py
new file mode 100644
index 0000000..ecb35ee
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/async-pull-mibs-from-multiple-agents-at-once.py
@@ -0,0 +1,86 @@
+"""
+Walk multiple Agents at once
+++++++++++++++++++++++++++++
+
+Iterate over MIBs of multiple SNMP Agents asynchronously using the
+following options:
+
+* with SNMPv1, community 'public' and
+ with SNMPv2c, community 'public' and
+ with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy
+* over IPv4/UDP and
+ over IPv6/UDP
+* to an Agent at demo.snmplabs.com:161 and
+ to an Agent at [::1]:161
+* for multiple MIB subtrees and tables
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+# List of targets in the followin format:
+# ( ( authData, transportTarget, varNames ), ... )
+targets = (
+ # 1-st target (SNMPv1 over IPv4/UDP)
+ ( CommunityData('public', mpModel=0),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('1.3.6.1.2.1')),
+ ObjectType(ObjectIdentity('1.3.6.1.3.1')) ) ),
+ # 2-nd target (SNMPv2c over IPv4/UDP)
+ ( CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('1.3.6.1.4.1')), ) ),
+ # 3-nd target (SNMPv3 over IPv4/UDP)
+ ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), ) ),
+ # 4-th target (SNMPv3 over IPv6/UDP)
+ ( UsmUserData('usr-md5-none', 'authkey1'),
+ Udp6TransportTarget(('::1', 161)),
+ ( ObjectType(ObjectIdentity('IF-MIB', 'ifTable')), ) )
+ # N-th target
+ # ...
+)
+
+# Wait for responses or errors, submit GETNEXT requests for further OIDs
+def cbFun(snmpEngine, sendRequestHandle, errorIndication,
+ errorStatus, errorIndex, varBindTable, cbCtx):
+ (varBindHead, authData, transportTarget) = cbCtx
+ print('%s via %s' % (authData, transportTarget))
+ if errorIndication:
+ print(errorIndication)
+ return
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
+ )
+ )
+ return
+ else:
+ for idx, varBind in enumerate(varBindTable[-1]):
+ if varBind[1] is not None and varBindHead[idx] <= varBind[0]:
+ break # still in table
+ else:
+ print('went out of table at %s' % (name, ))
+ return
+
+ for varBindRow in varBindTable:
+ for varBind in varBindRow:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
+
+ return True # continue table retrieval
+
+snmpEngine = SnmpEngine()
+
+cmdGen = AsyncCommandGenerator()
+
+# Submit initial GETNEXT requests and wait for responses
+for authData, transportTarget, varBinds in targets:
+ varBindHead = [ x[0] for x in cmdGen.makeVarBinds(snmpEngine, varBinds ) ]
+ cmdGen.nextCmd(
+ snmpEngine, authData, transportTarget, ContextData(), varBinds,
+ # User-space callback function and its context
+ (cbFun, (varBindHead, authData, transportTarget))
+ )
+
+snmpEngine.transportDispatcher.runDispatcher()
diff --git a/examples/hlapi/asyncore/manager/cmdgen/async-query-multiple-snmp-engines.py b/examples/hlapi/asyncore/manager/cmdgen/async-query-multiple-snmp-engines.py
new file mode 100644
index 0000000..1ce32ae
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/async-query-multiple-snmp-engines.py
@@ -0,0 +1,101 @@
+"""
+Multiple SNMP engines
++++++++++++++++++++++
+
+Send multiple SNMP GET requests to multiple peers using multiple
+independend SNMP engines. Deal with peers asynchronously. SNMP options
+are:
+
+* with SNMPv1, community 'public' and
+ with SNMPv2c, community 'public' and
+ with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy
+* over IPv4/UDP and
+ over IPv6/UDP
+* to an Agent at demo.snmplabs.com:161 and
+ to an Agent at [::1]:161
+* for instances of SNMPv2-MIB::sysDescr.0 and
+ SNMPv2-MIB::sysLocation.0 MIB objects
+
+Within this script we have a single asynchronous TransportDispatcher
+and a single UDP-based transport serving two independent SNMP engines.
+We use a single instance of AsyncCommandGenerator with each of
+SNMP Engines to comunicate GET command request to remote systems.
+
+When we receive a [response] message from remote system we use
+a custom message router to choose what of the two SNMP engines
+data packet should be handed over. The selection criteria we
+employ here is based on peer's UDP port number. Other selection
+criterias are also possible.
+
+"""#
+from pysnmp.hlapi.asyncore import *
+from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher
+
+# List of targets in the following format:
+# ( ( authData, transportTarget, varNames ), ... )
+targets = (
+ # 1-st target (SNMPv1 over IPv4/UDP)
+ ( CommunityData('public', mpModel=0),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ),
+ # 2-nd target (SNMPv2c over IPv4/UDP)
+ ( CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 1161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ),
+ # 3-nd target (SNMPv3 over IPv4/UDP)
+ ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 2161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) )
+ # N-th target
+ # ...
+)
+
+# Wait for responses or errors
+def cbFun(snmpEngine, sendRequestHandle, errorIndication,
+ errorStatus, errorIndex, varBinds, cbCtx):
+ (snmpEngine, authData, transportTarget) = cbCtx
+ print('snmpEngine %s: %s via %s' %
+ (snmpEngine.snmpEngineID.prettyPrint(), authData, transportTarget)
+ )
+ if errorIndication:
+ print(errorIndication)
+ return 1
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ return 1
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
+
+# Instantiate the single transport dispatcher object
+transportDispatcher = AsyncoreDispatcher()
+
+# Setup a custom data routing function to select snmpEngine by transportDomain
+transportDispatcher.registerRoutingCbFun(
+ lambda td,ta,d: ta[1] % 3 and 'A' or 'B'
+)
+
+snmpEngineA = SnmpEngine()
+snmpEngineA.registerTransportDispatcher(transportDispatcher, 'A')
+
+snmpEngineB = SnmpEngine()
+snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B')
+
+cmdGen = AsyncCommandGenerator()
+
+for authData, transportTarget, varBinds in targets:
+ snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \
+ snmpEngineA or snmpEngineB
+ cmdGen.getCmd(
+ snmpEngine, authData, transportTarget, ContextData(), varBinds,
+ (cbFun, (snmpEngine, authData, transportTarget))
+ )
+
+transportDispatcher.runDispatcher()
diff --git a/examples/hlapi/asyncore/manager/cmdgen/coerce-set-value-to-mib-spec.py b/examples/hlapi/asyncore/manager/cmdgen/coerce-set-value-to-mib-spec.py
new file mode 100644
index 0000000..bbcac86
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/coerce-set-value-to-mib-spec.py
@@ -0,0 +1,39 @@
+"""
+Coerce value to SET to MIB spec
++++++++++++++++++++++++++++++++
+
+Send SNMP SET request using the following options:
+
+* with SNMPv2c, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* setting SNMPv2-MIB::sysName.0 to new value (type taken from MIB)
+
+Functionally similar to:
+
+| $ snmpset -v2c -c public demo.snmplabs.com SNMPv2-MIB::sysDescr.0 \
+| = "new system name"
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ setCmd(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1),
+ 'new system name'))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/custom-asn1-mib-search-path.py b/examples/hlapi/asyncore/manager/cmdgen/custom-asn1-mib-search-path.py
new file mode 100644
index 0000000..445d665
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/custom-asn1-mib-search-path.py
@@ -0,0 +1,39 @@
+"""
+Custom ASN.1 MIB path
++++++++++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv2c, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for IF-MIB::ifInOctets.1 MIB object
+* pass non-default ASN.1 MIB source to MIB compiler
+
+Functionally similar to:
+
+| $ snmpget -v2c -c public -M /usr/share/snmp demo.snmplabs.com \
+| IF-MIB::ifInOctets.1
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1).addAsn1MibSource('file:///usr/share/snmp', 'http://mibs.snmplabs.com/asn1/@mib@')))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py b/examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py
new file mode 100644
index 0000000..2e84bba
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py
@@ -0,0 +1,45 @@
+"""
+Custom ContextEngineId and ContextName
+++++++++++++++++++++++++++++++++++++++
+
+Send SNMP SET request using the following options:
+
+* with SNMPv3 with user 'usr-md5-none', MD5 auth and no privacy protocols
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* addressing particular set of Managed Objects at remote SNMP Engine by:
+ * contextEngineId 0x80004fb805636c6f75644dab22cc and
+ * contextName 'a172334d7d97871b72241397f713fa12'
+* setting SNMPv2-MIB::sysName.0 to new value (type taken from MIB)
+
+Functionally similar to:
+
+| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 \
+| -E 80004fb805636c6f75644dab22cc -n a172334d7d97871b72241397f713fa12 \
+| demo.snmplabs.com \
+| SNMPv2-MIB::sysORDescr.1 = "new system name"
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ setCmd(SnmpEngine(),
+ UsmUserData('usr-md5-none', 'authkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(contextEngineId=OctetString(hexValue='80004fb805636c6f75644dab22cc'),
+ contextName='da761cfc8c94d3aceef4f60f049105ba'),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1),
+ 'new system name'))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid.py b/examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid.py
new file mode 100644
index 0000000..d8e19ab
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/custom-contextengineid.py
@@ -0,0 +1,43 @@
+"""
+Custom ContextEngineId
+++++++++++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols
+* use remote SNMP Engine ID 0x80004fb805636c6f75644dab22cc (USM
+ autodiscovery will run)
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* setting SNMPv2-MIB::sysName.0 to new value (type coerced from MIB)
+
+Functionally similar to:
+
+| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 \
+| -E 80004fb805636c6f75644dab22cc demo.snmplabs.com \
+| SNMPv2-MIB::sysORDescr.1 = "new system name"
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ setCmd(SnmpEngine(),
+ UsmUserData('usr-md5-des', 'authkey1', 'privkey1',
+ securityEngineId=OctetString(hexValue='80004fb805636c6f75644dab22cc')),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0),
+ 'new system name'))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/custom-pysnmp-mibs-search-path.py b/examples/hlapi/asyncore/manager/cmdgen/custom-pysnmp-mibs-search-path.py
new file mode 100644
index 0000000..e49ef4b
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/custom-pysnmp-mibs-search-path.py
@@ -0,0 +1,45 @@
+"""
+Custom PySNMP MIBs location
++++++++++++++++++++++++++++
+
+Send a series of SNMP GETBULK requests using the following options:
+
+* with SNMPv3, user 'usr-none-none', no authentication, no privacy
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for all OIDs within TCP-MIB::tcpConnTable column
+* TCP-MIB Python module will be searched by a user-specified filesystem
+ path (/opt/mib/pysnmp) and in Python package (python_packaged_mibs)
+ which should be in sys.path
+
+Functionally similar to:
+
+| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 \
+| demo.snmplabs.com TCP-MIB::tcpConnTable
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in bulkCmd(SnmpEngine(),
+ UsmUserData('usr-none-none'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ 0, 50,
+ ObjectType(ObjectIdentity('TCP-MIB', 'tcpConnTable').addMibSource('/opt/mibs/pysnmp').addMibSource('python_packaged_mibs')),
+ lexicographicMode=False):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/custom-timeout-and-retries.py b/examples/hlapi/asyncore/manager/cmdgen/custom-timeout-and-retries.py
new file mode 100644
index 0000000..a6965fe
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/custom-timeout-and-retries.py
@@ -0,0 +1,53 @@
+"""
+Custom request timeout
+++++++++++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv2c, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for an OID in string form
+* use custom timeout and request retries values
+
+Transport timing settings (maximum number of request retries and
+individual request timeout in seconds) can be set on a per-target basis
+as explained by the code that follows.
+
+Keep in mind that while timeout value can be specified in fractions of a
+second, default pysnmp timer resolution is quite low (about 0.5 sec)
+so there's no much point in using timeouts which is not a multiple of 0.5
+Internal timer can be programmatically adjusted to finer resolution if needed.
+
+If retries value is set to 0, pysnmp will issue a single request. Even
+if no response arrives, there will be no retry. Likewise, retries=1
+means one initial request plus one retry.
+
+Functionally similar to:
+
+| $ snmpget -v1 -c public demo.snmplabs.com 1.3.6.1.2.1.1.1.0
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(
+ ('demo.snmplabs.com', 161), timeout=1.5, retries=0
+ ),
+ ContextData(),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0')))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/custom-v3-security-name.py b/examples/hlapi/asyncore/manager/cmdgen/custom-v3-security-name.py
new file mode 100644
index 0000000..77c4cf6
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/custom-v3-security-name.py
@@ -0,0 +1,38 @@
+"""
+Custom SecurityName
++++++++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv3, user 'usr-md5-none', securityName 'myuser'
+ MD5 authentication, no privacy
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for an OID in text form
+
+The securityName parameter can be thought as an alias to userName and
+allows you to address a USM Table row just as userName does. However
+securityName can be made human-readable, also it is not an index in
+usmUserTable, thus duplicate securityName parameters are possible.
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ UsmUserData('usr-md5-none', 'authkey1', securityName='myuser'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0')))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py b/examples/hlapi/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py
new file mode 100644
index 0000000..3967ab6
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py
@@ -0,0 +1,42 @@
+"""
+GET over IPv6
++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols
+* over IPv6/UDP
+* to an Agent at [::1]:161
+* for three OIDs in string form
+
+Functionally similar to:
+
+| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \
+| udp6:[::1]:161 \
+| 1.3.6.1.2.1.1.1.0 \
+| 1.3.6.1.2.1.1.2.0 \
+| 1.3.6.1.2.1.1.3.0
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ Udp6TransportTarget(('::1', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0')),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.2.0')),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.3.0')))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-index.py b/examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-index.py
new file mode 100644
index 0000000..6b382ea
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-index.py
@@ -0,0 +1,41 @@
+"""
+GET table row
++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv3, user 'usr-none-none', no authentication, no privacy
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for IF-MIB::ifInOctets.1 and IF-MIB::ifOutOctets.1 MIB object
+* perform response OIDs and values resolution at MIB
+
+Functionally similar to:
+
+| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \
+| demo.snmplabs.com \
+| IF-MIB::ifInOctets.1 IF-MIB::ifOutOctets.1
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ UsmUserData('usr-none-none'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifOutOctets', 1)))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-multiple-indices.py b/examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-multiple-indices.py
new file mode 100644
index 0000000..e344dc0
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/get-table-object-by-multiple-indices.py
@@ -0,0 +1,46 @@
+"""
+Fetch table row by composite index
+++++++++++++++++++++++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv3, user 'usr-sha-aes128', SHA auth, AES128 privacy
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for TCP-MIB::tcpConnLocalAddress."0.0.0.0".22."0.0.0.0".0 MIB object
+
+Functionally similar to:
+
+| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \
+| -a SHA -x AES \
+| demo.snmplabs.com \
+| TCP-MIB::tcpConnLocalAddress."0.0.0.0".22."0.0.0.0".0
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1',
+ authProtocol=usmHMACSHAAuthProtocol,
+ privProtocol=usmAesCfb128Protocol ),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('TCP-MIB',
+ 'tcpConnLocalAddress',
+ '0.0.0.0', 22,
+ '0.0.0.0', 0))
+ )
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py b/examples/hlapi/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py
new file mode 100644
index 0000000..f30ae1e
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py
@@ -0,0 +1,48 @@
+"""
+Fetch scalar and table variables
+++++++++++++++++++++++++++++++++
+
+Send a series of SNMP GETBULK requests using the following options:
+
+* with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols
+* over IPv6/UDP
+* to an Agent at [::1]:161
+* with values non-repeaters = 1, max-repetitions = 25
+* for IP-MIB::ipAdEntAddr and all columns of the IF-MIB::ifEntry table
+* stop when response OIDs leave the scopes of the table
+
+Functionally similar to:
+
+| $ snmpbulkwalk -v3 -lauthPriv -u usr-md5-des -A authkey1 -X privkey1 \
+| -Cn1, -Cr25 \
+| demo.snmplabs.com \
+| IP-MIB::ipAdEntAddr \
+| IP-MIB::ipAddrEntry
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in bulkCmd(SnmpEngine(),
+ UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ Udp6TransportTarget(('::1', 161)),
+ ContextData(),
+ 1, 25,
+ ObjectType(ObjectIdentity('IP-MIB', 'ipAdEntAddr')),
+ ObjectType(ObjectIdentity('IP-MIB', 'ipAddrEntry')),
+ lexicographicMode=False):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-packets.py b/examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-packets.py
new file mode 100644
index 0000000..0cf9e0f
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-packets.py
@@ -0,0 +1,44 @@
+"""
+Walk Agent, limit number of packets
++++++++++++++++++++++++++++++++++++
+
+Send a series of SNMP GETBULK requests using the following options:
+
+* with SNMPv3, user 'usr-none-none', no authentication, no privacy
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for all OIDs past SNMPv2-MIB::system
+* run till end-of-mib condition is reported by Agent OR
+ maxCalls == 10 request-response interactions occur
+
+Functionally similar to:
+
+| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 \
+| demo.snmplabs.com SNMPv2-MIB::system
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in bulkCmd(SnmpEngine(),
+ UsmUserData('usr-none-none'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ 0, 50,
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')),
+ maxCalls=10):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-variables.py b/examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-variables.py
new file mode 100644
index 0000000..ec2abdd
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/getbulk-limit-number-of-variables.py
@@ -0,0 +1,47 @@
+"""
+Walk MIB, limit number of response rows
++++++++++++++++++++++++++++++++++++++++
+
+Send a series of SNMP GETBULK requests using the following options:
+
+* with SNMPv2c, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* with values non-repeaters = 0, max-repetitions = 25
+* for two OIDs in string form
+* stop when response OIDs leave the scopes of initial OIDs OR
+ number of response rows reach fixed value (20)
+
+Functionally similar to:
+
+| $ snmpbulkwalk -v2c -c public demo.snmplabs.com \
+| -Cn0 -Cr25 \
+| 1.3.6.1.2.1.2.2 1.3.6.1.2.1.2.3
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in bulkCmd(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ 0, 25,
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2')),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.2.3')),
+ lexicographicMode=False, maxRows=20):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/getnext-limit-number-of-variables.py b/examples/hlapi/asyncore/manager/cmdgen/getnext-limit-number-of-variables.py
new file mode 100644
index 0000000..2844bfa
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/getnext-limit-number-of-variables.py
@@ -0,0 +1,46 @@
+"""
+Fetch fixed amount of MIB variables
++++++++++++++++++++++++++++++++++++
+
+Send a series of SNMP GETNEXT requests using the following options:
+
+* with SNMPv3, user 'usr-sha-aes128', SHA auth, AES128 privacy
+* over UDP/IPv4
+* to an Agent at demo.snmplabs.com:161
+* for all OIDs past SNMPv2-MIB
+* run till end-of-mib condition is reported by Agent OR maxRows == 100
+* ignoring non-increasing OIDs whenever reported by Agent
+
+Functionally similar to:
+
+| $ snmpwalk -v3 -lauthPriv -u usr-sha-aes128 -A authkey1 -X privkey1 \
+| -a MD5 -x AES demo.snmplabs.com \
+| SNMPv2-MIB::system
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in nextCmd(SnmpEngine(),
+ UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1',
+ authProtocol=usmHMACSHAAuthProtocol,
+ privProtocol=usmAesCfb128Protocol),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('SNMPv2-MIB')),
+ maxRows=100, ignoreNonIncreasingOid=True):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py b/examples/hlapi/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py
new file mode 100644
index 0000000..ac66388
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py
@@ -0,0 +1,43 @@
+"""
+Fetch two OID branches
+++++++++++++++++++++++
+
+Send a series of SNMP GETNEXT requests using the following options:
+
+* with SNMPv2c, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for two OIDs in string form
+* stop when response OIDs leave the scopes of initial OIDs
+
+Functionally similar to:
+
+| $ snmpwalk -v2c -c public demo.snmplabs.com \
+| 1.3.6.1.2.1.2.2.1.2 1.3.6.1.2.1.2.2.1.3
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in nextCmd(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.2')),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.3')),
+ lexicographicMode=False):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-async-queries.py b/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-async-queries.py
new file mode 100644
index 0000000..0c6e9bf
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-async-queries.py
@@ -0,0 +1,85 @@
+"""
+Multiple concurrent queries
++++++++++++++++++++++++++++
+
+Send a bunch of different SNMP GET requests to different peers all at once,
+wait for responses asynchronously:
+
+* with SNMPv1, community 'public' and
+ with SNMPv2c, community 'public' and
+ with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy
+* over IPv4/UDP and
+ over IPv6/UDP
+* to an Agent at demo.snmplabs.com:161 and
+ to an Agent at [::1]:161
+* for instances of SNMPv2-MIB::sysDescr.0 and
+ SNMPv2-MIB::sysLocation.0 MIB objects
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+# List of targets in the followin format:
+# ( ( authData, transportTarget, varNames ), ... )
+targets = (
+ # 1-st target (SNMPv1 over IPv4/UDP)
+ ( CommunityData('public', mpModel=0),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ),
+ # 2-nd target (SNMPv2c over IPv4/UDP)
+ ( CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ),
+ # 3-nd target (SNMPv2c over IPv4/UDP) - same community and
+ # different transport address.
+ ( CommunityData('public'),
+ UdpTransportTarget(('localhost', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0))) ),
+ # 4-nd target (SNMPv3 over IPv4/UDP)
+ ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ),
+ # 5-th target (SNMPv3 over IPv6/UDP)
+ ( UsmUserData('usr-md5-none', 'authkey1'),
+ Udp6TransportTarget(('::1', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ),
+ # N-th target
+ # ...
+)
+
+# Wait for responses or errors
+def cbFun(snmpEngine, sendRequestHandle, errorIndication,
+ errorStatus, errorIndex, varBinds, cbCtx):
+ authData, transportTarget = cbCtx
+ print('%s via %s' % (authData, transportTarget))
+ if errorIndication:
+ print(errorIndication)
+ return True
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ return True
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
+
+snmpEngine = SnmpEngine()
+
+cmdGen = AsyncCommandGenerator()
+
+# Submit GET requests
+for authData, transportTarget, varNames in targets:
+ cmdGen.getCmd(
+ snmpEngine, authData, transportTarget, ContextData(), varNames,
+ # User-space callback function and its context
+ (cbFun, (authData, transportTarget))
+ )
+
+snmpEngine.transportDispatcher.runDispatcher()
diff --git a/examples/hlapi/asyncore/manager/cmdgen/multiple-get-calls.py b/examples/hlapi/asyncore/manager/cmdgen/multiple-get-calls.py
new file mode 100644
index 0000000..b17da65
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/multiple-get-calls.py
@@ -0,0 +1,47 @@
+"""
+Sequence Of GET's
++++++++++++++++++
+
+Send two SNMP GET requests in a row using the following options:
+
+* with SNMPv3, user 'usr-md5-none', MD5 authentication, no privacy
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for IF-MIB::ifInOctets.1 and IF-MIB::ifOutOctets.1 MIB objects
+
+Use a queue of MIB objects to query.
+
+The next() call is used to forward Python iterator to the position where it
+could consume input
+
+Functionally similar to:
+
+| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 demo.snmplabs.com \
+| IF-MIB::ifInOctets.1
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+queue = [ [ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)) ],
+ [ ObjectType(ObjectIdentity('IF-MIB', 'ifOutOctets', 1)) ] ]
+
+iter = getCmd(SnmpEngine(),
+ UsmUserData('usr-md5-none', 'authkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData())
+
+next(iter)
+
+while queue:
+ errorIndication, errorStatus, errorIndex, varBinds = iter.send(queue.pop())
+ if errorIndication:
+ print(errorIndication)
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/preload-pysnmp-mibs.py b/examples/hlapi/asyncore/manager/cmdgen/preload-pysnmp-mibs.py
new file mode 100644
index 0000000..080b5d1
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/preload-pysnmp-mibs.py
@@ -0,0 +1,43 @@
+"""
+Preload PySNMP MIBs
++++++++++++++++++++
+
+Send a series of SNMP GETNEXT requests using the following options:
+
+* with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols
+* over IPv6/UDP
+* to an Agent at [::1]:161
+* for all OIDs starting from 1.3.6
+* preload all Python MIB modules found in search path
+
+Functionally similar to:
+
+| $ snmpwalk -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \
+| -m ALL
+| udp6:[::1]:161 \
+| 1.3.6
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in nextCmd(SnmpEngine(),
+ UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ Udp6TransportTarget(('::1', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('1.3.6').loadMibs())):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py b/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py
new file mode 100644
index 0000000..479c504
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py
@@ -0,0 +1,42 @@
+"""
+Walk whole MIB
+++++++++++++++
+
+Send a series of SNMP GETNEXT requests using the following options:
+
+* with SNMPv3, user 'usr-md5-none', MD5 authentication, no privacy
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for all OIDs in IF-MIB
+* stop when response OIDs leave the scopes of the table
+
+Functionally similar to:
+
+| $ snmpwalk -v3 -lauthPriv -u usr-md5-none -A authkey1 -X privkey1 \
+| demo.snmplabs.com IF-MIB::
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in nextCmd(SnmpEngine(),
+ UsmUserData('usr-md5-none', 'authkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB')),
+ lexicographicMode=False):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/pull-whole-snmp-table.py b/examples/hlapi/asyncore/manager/cmdgen/pull-whole-snmp-table.py
new file mode 100644
index 0000000..3c3f40b
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/pull-whole-snmp-table.py
@@ -0,0 +1,53 @@
+"""
+Fetch whole SNMP table
+++++++++++++++++++++++
+
+Send a series of SNMP GETNEXT requests using the following options:
+
+* with SNMPv1, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for some columns of the IF-MIB::ifEntry table
+* stop when response OIDs leave the scopes of initial OIDs
+
+Functionally similar to:
+
+| $ snmpwalk -v1 -c public demo.snmplabs.com \
+| IF-MIB::ifDescr \
+| IF-MIB::ifType \
+| IF-MIB::ifMtu \
+| IF-MIB::ifSpeed \
+| IF-MIB::ifPhysAddress \
+| IF-MIB::ifType \
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, \
+ errorIndex, \
+ varBinds in nextCmd(SnmpEngine(),
+ CommunityData('public', mpModel=0),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifDescr')),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifType')),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifMtu')),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifSpeed')),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifPhysAddress')),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifType')),
+ lexicographicMode=False):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/query-agents-from-multuple-threads.py b/examples/hlapi/asyncore/manager/cmdgen/query-agents-from-multuple-threads.py
new file mode 100644
index 0000000..442855a
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/query-agents-from-multuple-threads.py
@@ -0,0 +1,127 @@
+"""
+Query Agents from multiple threads
+++++++++++++++++++++++++++++++++++
+
+Send a bunch of SNMP GET requests simultaneously using the following options:
+
+* process 5 GET requests in 3 parallel threads
+* with SNMPv1, community 'public' and
+ with SNMPv2c, community 'public' and
+ with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy
+* over IPv4/UDP and
+ over IPv6/UDP
+* to an Agent at demo.snmplabs.com:161 and
+ to an Agent at [::1]:161
+* for instances of SNMPv2-MIB::sysDescr.0 and
+ SNMPv2-MIB::sysLocation.0 MIB objects
+
+"""#
+from sys import version_info
+if version_info[0] == 2:
+ from Queue import Queue
+else:
+ from queue import Queue
+from threading import Thread
+from pysnmp.hlapi.asyncore import *
+
+# List of targets in the followin format:
+# ( ( authData, transportTarget, varNames ), ... )
+targets = (
+ # 1-st target (SNMPv1 over IPv4/UDP)
+ ( CommunityData('public', mpModel=0),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))),
+ # 2-nd target (SNMPv2c over IPv4/UDP)
+ ( CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))),
+ # 3-nd target (SNMPv2c over IPv4/UDP) - same community and
+ # different transport address.
+ ( CommunityData('public'),
+ UdpTransportTarget(('localhost', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0)))),
+ # 4-nd target (SNMPv3 over IPv4/UDP)
+ ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ))),
+ # 5-th target (SNMPv3 over IPv6/UDP)
+ ( UsmUserData('usr-md5-none', 'authkey1'),
+ Udp6TransportTarget(('::1', 161)),
+ ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))),
+ # N-th target
+ # ...
+)
+
+class Worker(Thread):
+ def __init__(self, requests, responses):
+ Thread.__init__(self)
+ self.snmpEngine = SnmpEngine()
+ self.requests = requests
+ self.responses = responses
+ self.setDaemon(True)
+ self.start()
+
+ def run(self):
+ while True:
+ authData, transportTarget, varBinds = self.requests.get()
+ self.responses.append(
+ next(
+ getCmd(
+ self.snmpEngine,
+ authData, transportTarget, ContextData(), *varBinds
+ )
+ )
+ )
+ if hasattr(self.requests, 'task_done'): # 2.5+
+ self.requests.task_done()
+
+class ThreadPool:
+ def __init__(self, num_threads):
+ self.requests = Queue(num_threads)
+ self.responses = []
+ for _ in range(num_threads):
+ Worker(self.requests, self.responses)
+
+ def addRequest(self, authData, transportTarget, varBinds):
+ self.requests.put((authData, transportTarget, varBinds))
+
+ def getResponses(self): return self.responses
+
+ def waitCompletion(self):
+ if hasattr(self.requests, 'join'):
+ self.requests.join() # 2.5+
+ else:
+ from time import sleep
+ # this is a lame substitute for missing .join()
+ # adding an explicit synchronization might be a better solution
+ while not self.requests.empty():
+ sleep(1)
+
+pool = ThreadPool(3)
+
+# Submit GET requests
+for authData, transportTarget, varBinds in targets:
+ pool.addRequest(authData, transportTarget, varBinds)
+
+# Wait for responses or errors
+pool.waitCompletion()
+
+# Walk through responses
+for errorIndication, errorStatus, errorIndex, varBinds in pool.getResponses():
+ print('Response for %s from %s:' % (authData, transportTarget))
+ if errorIndication:
+ print(errorIndication)
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/set-multiple-scalar-values.py b/examples/hlapi/asyncore/manager/cmdgen/set-multiple-scalar-values.py
new file mode 100644
index 0000000..b2b67eb
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/set-multiple-scalar-values.py
@@ -0,0 +1,49 @@
+"""
+SET scalars values
+++++++++++++++++++
+
+Send SNMP SET request using the following options:
+
+* with SNMPv1, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* setting three var-bindings to new values
+
+Please note, that in this example MIB lookup is only used
+for the second var-bindins. For the rest, value types are
+inferred from passed objects.
+
+Functionally similar to:
+
+| $ snmpset -v1 -c public demo.snmplabs.com \
+| 1.3.6.1.2.1.1.9.1.2.1 o 1.3.6.1.4.1.20408.1.1 \
+| 1.3.6.1.2.1.1.9.1.2.1 = 1.3.6.1.4.1.20408.1.1 \
+| 1.3.6.1.2.1.1.9.1.3.1 s "new system name"
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ setCmd(SnmpEngine(),
+ CommunityData('public', mpModel=0),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.9.1.2.1'),
+ ObjectIdentifier('1.3.6.1.4.1.20408.1.1')),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.9.1.2.1'),
+ '1.3.6.1.4.1.20408.1.1'),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.9.1.3.1'),
+ OctetString('new system name')))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/specific-v3-engine-id.py b/examples/hlapi/asyncore/manager/cmdgen/specific-v3-engine-id.py
new file mode 100644
index 0000000..f7db38f
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/specific-v3-engine-id.py
@@ -0,0 +1,86 @@
+"""
+Discover SNMPv3 SecurityEngineId
+++++++++++++++++++++++++++++++++
+
+Send SNMP GET request using the following scenario and options:
+
+* try to communicate with a SNMPv3 Engine using:
+
+* a non-existing user
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+
+* if remote SNMP Engine ID is discovered, send SNMP GET request:
+
+* with SNMPv3, user 'usr-md5-none', MD5 authentication, no privacy
+ at discovered securityEngineId
+* to the same SNMP Engine ID
+* for an OID in text form
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+snmpEngine = SnmpEngine()
+
+transportTarget = UdpTransportTarget(('demo.snmplabs.com', 161))
+
+#
+# To discover remote SNMP EngineID we will tap on SNMP engine inner workings
+# by setting up execution point observer setup on INTERNAL class PDU processing
+#
+
+observerContext = {}
+
+# Register a callback to be invoked at specified execution point of
+# SNMP Engine and passed local variables at execution point's local scope
+snmpEngine.observer.registerObserver(
+ lambda e,p,v,c: c.update(securityEngineId=v['securityEngineId']),
+ 'rfc3412.prepareDataElements:internal',
+ cbCtx=observerContext
+)
+
+# Send probe SNMP request with invalid credentials
+
+authData = UsmUserData('non-existing-user')
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(snmpEngine, authData, transportTarget, ContextData(),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)))
+)
+
+# See if our SNMP engine received REPORT PDU containing securityEngineId
+
+if 'securityEngineId' not in observerContext:
+ print("Can't discover peer EngineID, errorIndication: %s" % errorIndication)
+ raise Exception()
+
+securityEngineId = observerContext.pop('securityEngineId')
+
+print('Remote securityEngineId = %s' % securityEngineId.prettyPrint())
+
+#
+# Query remote SNMP Engine using usmUserTable entry configured for it
+#
+
+authData = UsmUserData('usr-md5-none', 'authkey1',
+ securityEngineId=securityEngineId)
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(snmpEngine,
+ authData,
+ transportTarget,
+ ContextData(),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0')))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for name, val in varBinds:
+ print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/usm-md5-des.py b/examples/hlapi/asyncore/manager/cmdgen/usm-md5-des.py
new file mode 100644
index 0000000..cdd6ce3
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/usm-md5-des.py
@@ -0,0 +1,39 @@
+"""
+SNMPv3: auth MD5, privacy DES
++++++++++++++++++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv3, user 'usr-md5-des', MD5 authentication, DES encryption
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for IF-MIB::ifInOctets.1 MIB object
+
+Functionally similar to:
+
+| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \
+| demo.snmplabs.com \
+| IF-MIB::ifInOctets.1
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/usm-md5-none.py b/examples/hlapi/asyncore/manager/cmdgen/usm-md5-none.py
new file mode 100644
index 0000000..363bddb
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/usm-md5-none.py
@@ -0,0 +1,38 @@
+"""
+SNMPv3: auth MD5, no privacy
+++++++++++++++++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv3, user 'usr-md5-none', MD5 authentication, no privacy
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for IF-MIB::ifInOctets.1 MIB object
+
+Functionally similar to:
+
+| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 demo.snmplabs.com \
+| IF-MIB::ifInOctets.1
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ UsmUserData('usr-md5-none', 'authkey1'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/usm-none-none.py b/examples/hlapi/asyncore/manager/cmdgen/usm-none-none.py
new file mode 100644
index 0000000..5049a7c
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/usm-none-none.py
@@ -0,0 +1,39 @@
+"""
+SNMPv3: no auth, no privacy
++++++++++++++++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv3, user 'usr-none-none', no authentication, no encryption
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for IF-MIB::ifInOctets.1 MIB object
+
+Functionally similar to:
+
+| $ snmpget -v3 -l noAuthNoPriv -u usr-none-none
+| demo.snmplabs.com \
+| IF-MIB::ifInOctets.1
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ UsmUserData('usr-none-none'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/usm-sha-aes128.py b/examples/hlapi/asyncore/manager/cmdgen/usm-sha-aes128.py
new file mode 100644
index 0000000..1a1c0cb
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/usm-sha-aes128.py
@@ -0,0 +1,57 @@
+"""
+SNMPv3: auth SHA, privacy AES128
+++++++++++++++++++++++++++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv3, user 'usr-sha-aes', SHA authentication, AES128 encryption
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for SNMPv2-MIB::sysDescr.0 MIB object
+
+Available authentication protocols:
+
+#. usmHMACMD5AuthProtocol
+#. usmHMACSHAAuthProtocol
+#. usmNoAuthProtocol
+
+Available privacy protocols:
+
+#. usmDESPrivProtocol
+#. usm3DESEDEPrivProtocol
+#. usmAesCfb128Protocol
+#. usmAesCfb192Protocol
+#. usmAesCfb256Protocol
+#. usmNoPrivProtocol
+
+Functionally similar to:
+
+| $ snmpget -v3 -l authPriv -u usr-sha-aes -A authkey1 -X privkey1 \
+| -a SHA -x AES \
+| demo.snmplabs.com \
+| SNMPv2-MIB::sysDescr.0
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ UsmUserData('usr-sha-aes', 'authkey1', 'privkey1',
+ authProtocol=usmHMACSHAAuthProtocol,
+ privProtocol=usmAesCfb128Protocol),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/v1-get.py b/examples/hlapi/asyncore/manager/cmdgen/v1-get.py
new file mode 100644
index 0000000..7d417ef
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/v1-get.py
@@ -0,0 +1,37 @@
+"""
+SNMPv1
+++++++
+
+Send SNMP GET request using the following options:
+
+ * with SNMPv1, community 'public'
+ * over IPv4/UDP
+ * to an Agent at demo.snmplabs.com:161
+ * for two instances of SNMPv2-MIB::sysDescr.0 MIB object,
+
+Functionally similar to:
+
+| $ snmpget -v1 -c public demo.snmplabs.com SNMPv2-MIB::sysDescr.0
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ CommunityData('public', mpModel=0),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py b/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py
new file mode 100644
index 0000000..a11c48c
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py
@@ -0,0 +1,39 @@
+"""
+SNMPv2c
++++++++
+
+Send SNMP GET request using the following options:
+
+* with SNMPv2c, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for two OIDs in string form
+
+Functionally similar to:
+
+| $ snmpget -v2c -c public demo.snmplabs.com 1.3.6.1.2.1.1.1.0 \
+| 1.3.6.1.2.1.1.6.0
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+errorIndication, errorStatus, errorIndex, varBinds = next(
+ getCmd(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0')),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1.6.0')))
+)
+
+if errorIndication:
+ print(errorIndication)
+elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/v2c-getbulk.py b/examples/hlapi/asyncore/manager/cmdgen/v2c-getbulk.py
new file mode 100644
index 0000000..ff82017
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/v2c-getbulk.py
@@ -0,0 +1,46 @@
+"""
+Bulk walk MIB
++++++++++++++
+
+Send a series of SNMP GETBULK requests using the following options:
+
+* with SNMPv2c, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* with values non-repeaters = 0, max-repetitions = 25
+* for two OIDs in string form
+* stop when response OIDs leave the scopes of initial OIDs
+
+Functionally similar to:
+
+| $ snmpbulkwalk -v2c -c public demo.snmplabs.com \
+| -Cn0 -Cr25 \
+| 1.3.6.1.2.1.2.2 1.3.6.1.2.1.2.3
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in bulkCmd(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ 0, 25,
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2')),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.2.3')),
+ lexicographicMode=False):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/examples/hlapi/asyncore/manager/cmdgen/waive-mib-lookup.py b/examples/hlapi/asyncore/manager/cmdgen/waive-mib-lookup.py
new file mode 100644
index 0000000..595d7ad
--- /dev/null
+++ b/examples/hlapi/asyncore/manager/cmdgen/waive-mib-lookup.py
@@ -0,0 +1,45 @@
+"""
+Waive MIB lookup
+++++++++++++++++
+
+Perform SNMP GETNEXT operation with the following options:
+
+* with SNMPv2c, community 'public'
+* over IPv4/UDP
+* to an Agent at demo.snmplabs.com:161
+* for an OID in string form
+* do not resolve response OIDs and values into human-freidly form
+
+False lookupMib keyword arguments could make pysnmp waiving
+OIDs and values resolution in response variable-bindings, into human
+friendly form.
+
+Functionally similar to:
+
+| $ snmpwalk -v2c -c public -ObentU demo.snmplabs.com 1.3.6.1.2.1
+
+"""#
+from pysnmp.hlapi.asyncore import *
+
+for errorIndication, \
+ errorStatus, errorIndex, \
+ varBinds in nextCmd(SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('1.3.6.1.2.1.1')),
+ lookupMib=False):
+
+ if errorIndication:
+ print(errorIndication)
+ break
+ elif errorStatus:
+ print('%s at %s' % (
+ errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1][0] or '?'
+ )
+ )
+ break
+ else:
+ for varBind in varBinds:
+ print(' = '.join([ x.prettyPrint() for x in varBind ]))
diff --git a/pysnmp/entity/engine.py b/pysnmp/entity/engine.py
index 97844bf..6a45474 100644
--- a/pysnmp/entity/engine.py
+++ b/pysnmp/entity/engine.py
@@ -14,6 +14,8 @@ from pysnmp.entity import observer
from pysnmp import debug
from pysnmp import error
+__all__ = ['SnmpEngine']
+
class SnmpEngine:
"""Creates SNMP engine object.
@@ -39,7 +41,6 @@ class SnmpEngine:
Examples
--------
- >>> from pysnmp.entity.engine import SnmpEngine
>>> SnmpEngine()
SnmpEngine(snmpEngineID=OctetString(hexValue='0x80004fb80567726f6d6d69742'))
>>>
diff --git a/pysnmp/hlapi/__init__.py b/pysnmp/hlapi/__init__.py
new file mode 100644
index 0000000..07adb5a
--- /dev/null
+++ b/pysnmp/hlapi/__init__.py
@@ -0,0 +1,5 @@
+from pysnmp.proto.rfc1902 import *
+from pysnmp.smi.rfc1902 import *
+from pysnmp.hlapi.auth import *
+from pysnmp.hlapi.context import *
+from pysnmp.entity.engine import SnmpEngine
diff --git a/pysnmp/hlapi/asyncore/__init__.py b/pysnmp/hlapi/asyncore/__init__.py
index 2f815b6..9753462 100644
--- a/pysnmp/hlapi/asyncore/__init__.py
+++ b/pysnmp/hlapi/asyncore/__init__.py
@@ -1,4 +1,3 @@
-# This file is necessary to make this directory a package.
from pysnmp.proto.rfc1902 import *
from pysnmp.smi.rfc1902 import *
from pysnmp.hlapi.auth import *
diff --git a/pysnmp/hlapi/asyncore/_sync/cmdgen.py b/pysnmp/hlapi/asyncore/_sync/cmdgen.py
index 357cc52..5cdb290 100644
--- a/pysnmp/hlapi/asyncore/_sync/cmdgen.py
+++ b/pysnmp/hlapi/asyncore/_sync/cmdgen.py
@@ -428,9 +428,9 @@ def bulkCmd(snmpEngine, authData, transportTarget, contextData,
maxRepetitions : int
`maxRepetitions` MIB variables are requested in response for each
- of the remaining MIB variables in the request (e.g. excluding
- `nonRepeaters`). Remote SNMP engine may choose lesser value than
- requested.
+ of the remaining MIB variables in the request (e.g. excluding
+ `nonRepeaters`). Remote SNMP engine may choose lesser value than
+ requested.
\*varBinds : :py:class:`~pysnmp.smi.rfc1902.ObjectType`
One or more class instances representing MIB variables to place
@@ -462,7 +462,7 @@ def bulkCmd(snmpEngine, authData, transportTarget, contextData,
errorStatus : str
True value indicates SNMP PDU error.
errorIndex : int
- Non-zero value refers to *varBinds[errorIndex-1]
+ Non-zero value refers to \*varBinds[errorIndex-1]
varBinds : tuple
A sequence of :py:class:`~pysnmp.smi.rfc1902.ObjectType` class
instances representing MIB variables returned in SNMP response.
diff --git a/setup.py b/setup.py
index 7941703..7f189ad 100644
--- a/setup.py
+++ b/setup.py
@@ -104,11 +104,12 @@ params.update( {
'pysnmp.carrier.asyncio.dgram',
'pysnmp.entity',
'pysnmp.entity.rfc3413',
- 'pysnmp.entity.rfc3413.oneliner',
- 'pysnmp.entity.rfc3413.oneliner.sync',
- 'pysnmp.entity.rfc3413.oneliner.sync.compat',
'pysnmp.entity.rfc3413.twisted',
'pysnmp.entity.rfc3413.asyncio',
+ 'pysnmp.hlapi',
+ 'pysnmp.hlapi.asyncore',
+ 'pysnmp.hlapi.asyncore._sync',
+ 'pysnmp.hlapi.asyncore._sync.compat',
'pysnmp.proto',
'pysnmp.proto.mpmod',
'pysnmp.proto.secmod',