Mib2c

From Net-SNMP Wiki
Revision as of 21:37, 30 June 2011 by Wes (Talk | contribs) (Development Process Using mib2c)

Jump to: navigation, search

The mib2c script is badly named. It really should have been named mib2anything, as it's actually can provide output tailored to anything you might want to change MIB data into.

(Full Manual Page: mib2c)

mib2c Goals

mib2c was designed to:

  • Alleviate the task of producing identically similar code for each mib object
  • Be a generic MIB processing engine, capable of converting MIBs and MIB structures to any other format.
  • Provide an easy-as-possible getting started interface for new coders trying to write new code to support MIBs
Error creating thumbnail: Unable to save thumbnail to destination

Regeneratable Code

One second goal besides just generating code once and leaving it to the programmer to fill in the blanks, is to provide a framework for splitting code into two pieces:

  • code that needs to be maintained by a human implementing the MIB objects
  • code that needs only to be written by mib2c itself, and can be regenerated in the future to take advantage of new features produced by mib2c

Some of the mib2c output will contain both of these types of code, and code that can be regenerated/updated in the future is marked as such.

Development Process Using mib2c

The typical process for using mib2c follows this pattern:

  1. Write a MIB and objects for it (eg, tables and scalars)
  2. run mib2c on the MIB objects to generate code, producing:
    • code that should be edited to complete the implementation
    • code that should not be edited ("regeneratable").
  3. Edit the code to return value MIB data (or accept it when processing SETs)

Example mib2c input file

If you put this in file.conf:

 @open -@
 @foreach $t table@
     @foreach $c column@
         $c is a column of type $c.type at $c.objectID
     @end@
 @end@

And then run it on a table, such as the ifTable:

 # mib2c -c file.conf ifTable