TUT:mib2c-update
From Net-SNMP Wiki
Contents |
About mib2c-update
mib2c generates template code which you must customize. So what happens when the confiugration file you chose is updated to fix a bug or add a new feature? Traditionally, you have had to manually merge the changes into your code, or merge your customizations into a freshly generated code set. (see pseudo-algorithm for the manual steps needed).
The shell script mib2c-update is a wrapper around mib2c and other utilities to help you take advantage of updates to the configuration file you chose for your mib module without having to manually merge code changes.
If all goes well, there might not be any conflicts. If you changed any configuration option, or there were lots of changes to the configuration files, you may have to do quite a bit of manual patching.
Basic Configuration
mib2c-update does not take any commanline parameters. All configuration is kept in the file .mib2c-updaterc in the directory where the code is generated. This configuration file needs to contain two pieces of information: the table name, and the mib2c configuration file to use. The format is pretty basic:
# # example mib2c-update configuration file # # UPDATE_OID should contain the table for which code will be generated # UPDATE_OID=ipAddressTable # # UPDATE_CONF should contain the mib2c configuration file to be used # UPDATE_CONF=mib2c.mfd.conf
Those are the only required options. If you want to pass additional arguments to mib2c, you can set the options in UPDATE_MIB2C_OPTS:
UPDATE_MIB2C_OPTS="-q -f ipAddress"
You can also configure the directories that mib2c-update will use to generate temporary code. The available options, and their defaults, are:
- UPDATE_CURR=.
- Determines where the current code is. The default is the current working directory.
- UPDATE_ORIG=.orig
- Determines where the original template code is. In this case, originial means the template used for the code in current.
- UPDATE_NEW=.new
- Determines where the new template code should be generated.
- UPDATE_PATCH=.patch
- Determines where the template and custom code patches should be generated.
- UPDATE_MERGED=.merged
- Determines where the merging of the new code with the patches should occur.
- UPDATE_BACKUP=.backup
- Determines where the current and original code will be backed up.
Running mib2c-update
Note: if you are trying to use mib2c-update after the fact (i.e. you originally generated you code with mib2c directly) skip ahead to using mib2c-update retroactively.
The first run of mib2c-update is very easy. Simply create your configuration file, .mib2c-updaterc, as described above, and then run mib2c-update. The temporary directories will be created, and mib2c will be run to generate the initial code.
... XXX: EXAMPLE RUN HERE ...
Once you have generated the code, I strongly recommend that you check it in to a source code version control system, such as CVS, Subversion, RCS, ClearCase or (shudder) Microsoft SourceSafe. This will help you recover if a bug in mib2-update causes any problems. Both the current and original directories should be put under version control.
Running mib2c-update
If you are trying to use mib2c-update after the fact (i.e. you originally generated you code with mib2c directly), you have to do a little work to be able to use mib2c-update.
... XXX: TBD ...
Manual updates
If you want to manage the process manually, it goes something like this:
- In a new directory (eg orig), generate the code for your table using the same mib2c configuration file and options that were originally used to generate the code.
- use diff to compare the unmodified template code to your existing code, and save the output to create a patch of your changes.
- in a new directory (eg new), generate the code for your table using the updated mib2c configuration files, but with the same options that were originally used to generate the code.
- use diff to compare the original template code to the updated template code, and save the output to create a patch of the configuration file changes.
- copy the new code to a new directory (eg merge), and apply the configuration file patch.
- apply your custome changes patch to the merge directory
- resolve any conflicts or failed patches.
Tutorial Sections
- Command Line Applications
- snmptranslate: learning about the MIB tree.
- snmpget: retrieving data from a host.
- snmpgetnext: retrieving unknown indexed data.
- snmpwalk: retrieving lots of data at once!
- snmptable: displaying a table.
- snmpset: peforming write operations.
- snmpbulkget: communicates with a network entity using SNMP GETBULK request
- snmpbulkwalk: retrieve a sub-tree of management values using SNMP GETBULK requests.
- snmptrap: Sending and receiving traps, and acting upon them.
- Traps/informs with SNMPv3: Sending and receiving SNMPv3 TRAPs and INFORMs
- Common command line options:
- Writing mib2c config files
- SNMP Daemons
- SNMP Agent (snmpd) Configuration
- SNMP Notification Receiver (snmptrapd)
- Agent Monitoring
- Coding Tutorials
- Client / Manager Coding Tutorials
- Agent Coding Tutorials
- Writing a mib module to serve information described by an SNMP MIB, and how to compile it into the net-snmp snmpd agent.
- Writing a Dynamically Loadable Object that can be loaded into the SNMP agent.
- Writing a Subagent that can be run to attach to the snmpd master agent.
- Writing a perl plugin to extend the agent using the NetSNMP::agent module.
- Using mib2c to help write an agent code template for you
- General mib2c Overview
- Using the mib2c-update script to recode your code
- mib2c.mfd.conf tutorial
- Header files and autoconf
- Building With Visual Studio 2005 Express
- Debugging SNMP Applications and Agent's
