TUT:mib2c-update
Contents
About mib2c-update
mib2c generates template code which you must customize. So what happens when the configuration 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 command-line parameters. All configuration information 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:
# # 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.
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
About the SNMP Protocol
These tutorial links talk about SNMP generically and how the protocol itself works. They are good introductory reading material and the concepts are important to understand before diving into the later tutorials about Net-SNMP itself.
- How SNMP Works: About the protocol itself (GETs, GETNEXTs, etc)
- What data is in SNMP: All about SNMP Management Information Bases (MIBs)
- Securing SNMP: How to use the SNMP protocol securely
Net-SNMP Command Line Applications
These tutorial pages discuss the command line tools provided in the Net-SNMP suite of tools. Nearly all the example commands in these tutorials works if you try it yourself, as they're all examples that talk to our online Net-SNMP test agent. Given them a shot!
- 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/USM: Sending and receiving SNMPv3/USM TRAPs and INFORMs
- Sending Traps/Informs via AgentX: Sending notifications from the command line through snmpd
- Common command line options:
- Writing mib2c config files
Application Configuration
All of our applications support configuration to allow you to customize how they behave.
Net-SNMP Daemons
Net-SNMP comes with two long-running daemons: a SNMP agent (snmpd) for responding to management requests and a notification receiver (snmptrapd) for receiving SNMP notifications.
- SNMP Agent (snmpd) Configuration
- SNMP Notification Receiver (snmptrapd)
- Agent Monitoring
Coding Tutorials
Net-SNMP comes with a highly flexible and extensible API. The API allows you to create your own commands, add extensions to the agent to support your own MIBs and perform specialized processing of notifications.
- Client / Manager Coding Tutorials
- Agent Coding Tutorials
- The Agent Architecture page might be worth reading before or after the agent coding tutorials, and describes how the Agent Helpers work under the hood.
- 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.
- Writing shell scripts to extend the agent
- 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
Debugging SNMP Applications and Agents
All our tools and applications have extensive debugging output. These tutorials talk about how the debugging system works and how you can add your own debugging statements to you code:
- Debugging output printed using the -D command line option
- Using -Ddump to display packet breakdowns
- Debugging using GDB
Operating System Specific Tutorials
- Building With Visual Studio 2005 Express
- Building Net-SNMP 64-bit with Visual C++ 2010 Express
- Net-Snmp on Ubuntu
- Net-SNMP and lm-sensors on Ubuntu 10.04
- Net-SNMP for windows: