Developing PySNMP based agent with Custom MIB

Let’s face it – PySNMP documentation is not very clear and well organized, yet for those of you willing to implement SNMP agent easily and efficiently, without the need to extend complicated C++ libraries (e.g. net-snmp) with dynamically loaded libraries, PySNMP might be a good start.

I followed Neal Charbonneau’s great tutorial and found it very helpful, but I needed an ability to define writable (SNMP SET) objects. The following code is more or less copy of Neal’s code, with ability to set testCount object from SNMP manager:

 

The following additions were made to Neal’s code:

  1. “private” area was added, with writable tree defined
  2. class Var from createVariable factory was extended to include writeCommit (and writeTest) functions
  3. The mapping between MIB object and MIB implementation (MibObject collection) was extended to include write function (it is left empty when read-only object is mapped)

Few additional comments:

  1. To use build-pysnmp-mib script you will probably need to set SMIPATH variable to the existing MIBS for importing them within your new MIB

     

One thought on “Developing PySNMP based agent with Custom MIB

  1. i was wondering how to translate oids from custom MIB on a trap receiver of snmp v1 or v2c, I’ve already gone sucessfully through the snmp trap receiver example, but it seems that the UPS trap messages (which i am interested in) gets translated through a generic MIB.

    any ideas ?

Leave a Reply

Your email address will not be published. Required fields are marked *