I'm doing some GUI prototyping with Python for an SNMP application. Looking around there seem to be a number of python libraries I could use. As I'm prototyping I value a nice clean easy API over speed and preferably a commonly packaged library. Obviously the package should be open source. So far I've been looking PySNMP, Twisted-Snmp, pynetsnmp and seafelt's libsnmp.
The most active project of "Security not my Problem" seems to be pycopia SNMP. I have no experience with any of them, but if you have troubles finding the correct one have a look at the mailinglist archives of the libraries to find the most active one. Those usually have the better API/implementation or at least more users.
I say the one I wrote last weekend:
http://code.google.com/p/multicore-snmp/
Full process based API to Net-SNMP which supports V1-V3.
Of the libraries you mention I'd single out the python net-snmp library and pysnmp. One of my criteria for choosing well supported libraries is are they in debian/ubuntu and these both pass that test.
Net-snmp does come with python bindings. Net-snmp is in some ways the de-facto snmp library (for linux at least) so it is probably a good choice in that respect. However net-snmp is an extrememly large and gangly C library (which I've spent rather a lot of time hacking on and reading the source code) which is a downside.
The other alternative is a pure python snmp library - pysnmp which seems like a sensible choice, though I haven't actually tried that one. The twisted wrapper for it could come in handy.
If I was starting a new SNMP development I'd try pysnmp to see how well it works, but the old faithful (py)net-snmp is always there if you need it.
If you just want a bit of light usage of snmp then you can use the net-snmp command line tools very easily, eg
snmpget -c password host -v1 enterprises.318.1.1.12.2.3.1.1.2.1
To read the power usage of an APC powerbar, which would work fine for prototyping I would have thought.
[edit: one year later]
I've now had a chance to try the pysnmp library.
I wasn't happy with the stable branch 2.x, but the development 4.x works and has a lots of good features, including
- MIB loading
- Reasonably simple oneliner interface
- Full support of set/get/walk with bulk versions of those
- Sync and Async interface
- Support for server (agent) and client (manager)
I found it moderately complicated to work with, but I managed to work it out with help from the docs and the source code.
Top tip: set os.environ['PYSNMP_MIB_DIR']
to point to directories with your own converted mibs in, and use build-pysnmp-mib
to make them, or if that doesn't work
smidump -k -f python My-MIB.txt | libsmi2pysnmp > My-MIB.py