SNMP is not really simple (PySNMP implementation takes 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:
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:
from pysnmp import debug # use specific flags or 'all' for full debugging debug.setLogger(debug.Debug('dsp', 'msgproc', 'secmode'))
For more details on PySNMP programming model and interfaces, please refer to the documentation.