summaryrefslogtreecommitdiff
path: root/docs/source/examples/contents.rst
blob: 8257a323479c2920287c32bdf4bec21f1e866474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
 
Examples scripts
================

.. toctree::
   :maxdepth: 2

SNMP is not really simple (PySNMP implementation takes over 15K lines of
Python code), but PySNMP tries to isolate the complexities and let you 
perform typical SNMP operations in a quick and intuitive way.

PySNMP offers three groups of programming interfaces to deal with 
SNMP protocol. In the order from most consice to most detailed those 
APIs are:

#. High-level API

   .. toctree::
      :maxdepth: 2

      /examples/v3arch/asyncore/oneliner/contents

#. Complete implementation of all official Standard SNMP Applications. It 
   should let you implement any SNMP operation defined in the standard. 

   This API comes in several transport varieties.

   #. Most mature and stable transport implementation is based on Python's
      bult-in asyncore module. So this API is called Native or Asyncore API.

      .. toctree::
         :maxdepth: 2

         /examples/v3arch/asyncore/contents

   #. Modern, co-routines based API takes shape of asyncio bindings 
      (Python 3.3+) or Trollius bindings (Python 2.6-3.4)

      .. toctree::
         :maxdepth: 2

         /examples/v3arch/asyncio/contents
         /examples/v3arch/trollius/contents

   #. Slightly aged, Twisted-based based API.

      .. toctree::
         :maxdepth: 2

         /examples/v3arch/twisted/contents

#. Packet-level API that lets you build SNMP messages from Python 
   objects and exchange them through asyncore transport (or you could 
   write your own). These interfaces are very low-level and aimed at 
   a rather specific programming tasks.

   .. toctree::
      :maxdepth: 2

      /examples/v1arch/asyncore/contents

Before doing cut&paste of the code below into your Python interpreter, 
make sure to install pysnmp and its dependencies by running pip or 
easy_install: ::

    # pip pysnmp

There's a public SNMP responder configured at *demo.snmplabs.com:161* to
let you run PySNMP examples scripts in a cut&paste fashion. If you 
wish to use your own SNMP Agent with these scripts, make sure to either 
configure your local snmpd and/or snmptrapd or use a valid address and 
SNMP credentials of your SNMP Agent in the examples to let them work.

If you find your PySNMP application behaving unexpectedly, try to enable 
a /more or less verbose/ built-in PySNMP debugging by adding the 
following snippet of code at the beginning of your application:

.. code-block:: python

    from pysnmp import debug

    # use specific flags or 'all' for full debugging
    debug.setLogger(debug.Debug('dsp', 'msgproc', 'secmode'))

Then run your app and watch stderr. The Debug initializer enables debugging 
for a particular PySNMP subsystem, 'all' enables full debugging. More 
specific flags are:

* io
* dsp
* msgproc
* secmod
* mibbuild
* mibview
* mibinstrum
* acl
* proxy
* app

For more details on PySNMP programming model and interfaces, please 
refer to the documentation.