AgentX Tutorial using Net-SNMP – Simple Table MIB for Dummies

Second in the series of implementing an AgentX agent I describe a simple table implementation. Net-SNMP provides multiple implementations from easy one to more elaborate ones. An approach should be accepted based on the need. For most of the needs MIB for Dummies work (mib2c -c mib2c.mfd.conf). Points to consider for using MIB for dummies are :

  1. Data could be cached and smaller time windows are acceptable where data may be stale compared to real world values (or application can implement a logic to mark cache expired on real value change)
  2. Data reloads are not resource intensive
  3. Data set for table is small so memory foot print of copying to cache will be small

MIB for Dummies gets implemented using Container provided by Net-SNMP where data is cached. So when a request comes in and Cache is empty or expired, it gets (re)loaded. For future requests if Cache is not stale, data will be provided from Cache. So that speeds up things but leaves a possibility that data may be stale because cache is not yet expired while data could have changed being in real-time. Note: Cache will be (re)loaded weather a single stat is requested (snmpget) or multiples (snmpwalk/bulkwalk etc). This is the reason that makes it inefficient for a large dataset or a dataset that’s reload is resource intensive. So use it sparingly.

One other thing to consider is that even though this method is inefficient, snmp polling is supposed to be rare event. SNMP relies heavily on traps or events which go from agent to NMS. SNMP polling is supposedly rare compared to trap traffic. That being said inefficiencies of Container Cached data are small compared to ease of code and management.

One other caveat is that if MIB has 10 tables, this method bloats up the number of steps and files that get generated. Each table has to be compiled (mib2c) separately  and then the code to load cache for that table has to be implemented. Net-SNMP provides a template code that loads data from File which is what I also describe in my Tutorial. But that is just to give an idea. Application may have internal data structures where data is stored and can be easily copied over to the Net-SNMP container.

So head over to my git repository and clone the code. Then extract code using right tags as described below.

git clone
git checkout step2_tables_autogenerated
git checkout step2_tables_implement