Difference between revisions of "TUT:mib2c config files"
(→Additional reading material) |
m (Fixed a grammatical error that was annoying me to no end.) |
||
(One intermediate revision by one other user not shown) | |||
Line 3: | Line 3: | ||
mib2c -c mib2c.genhtml.conf ifTable | mib2c -c mib2c.genhtml.conf ifTable | ||
− | The above command writes | + | The above command writes an html summary of the ifTable branch of the mib tree. It's probably much more readable than the average MIB file to many people. |
== Writing your own .conf file == | == Writing your own .conf file == | ||
Line 82: | Line 82: | ||
* [http://www.net-snmp.org/docs/man/mib2c.html the mib2c man page] | * [http://www.net-snmp.org/docs/man/mib2c.html the mib2c man page] | ||
* [http://www.net-snmp.org/docs/man/mib2c.conf.html the mib2c.conf man page] | * [http://www.net-snmp.org/docs/man/mib2c.conf.html the mib2c.conf man page] | ||
+ | |||
+ | {{TUT:LIST}} |
Latest revision as of 16:42, 26 October 2009
mib2c is actually very poorly named. It was originally designed as a mechanism for producing C-code from a MIB file. However, it really is just a template system. You can produce just about anything from a MIB if you can write a template about how you want the output to be. For example:
mib2c -c mib2c.genhtml.conf ifTable
The above command writes an html summary of the ifTable branch of the mib tree. It's probably much more readable than the average MIB file to many people.
Writing your own .conf file
The mib2c configuration file language is fairly easy to understand. See the mib2c configuration file manual page for details.
A quick preview: If you have a file that looks like this:
@open -@ @foreach $t table@ In table $t we have the following indexes: @foreach $i index@ $i (at $i.subid) which is of type $i.type @end@ And the following columns: @foreach $i nonindex@ $i (at $i.subid) which is of type $i.type @end@ @end@
and we run mib2c pointing to that file we get:
> mib2c -c MYFILE.conf ifTable writing to - In table ifTable we have the following indexes: ifIndex (at 1) which is of type ASN_INTEGER And the following columns: ifDescr (at 2) which is of type ASN_OCTET_STR ifType (at 3) which is of type ASN_INTEGER ifMtu (at 4) which is of type ASN_INTEGER ifSpeed (at 5) which is of type ASN_GAUGE ifPhysAddress (at 6) which is of type ASN_OCTET_STR ifAdminStatus (at 7) which is of type ASN_INTEGER ifOperStatus (at 8) which is of type ASN_INTEGER ifLastChange (at 9) which is of type ASN_TIMETICKS ifInOctets (at 10) which is of type ASN_COUNTER ifInUcastPkts (at 11) which is of type ASN_COUNTER ifInNUcastPkts (at 12) which is of type ASN_COUNTER ifInDiscards (at 13) which is of type ASN_COUNTER ifInErrors (at 14) which is of type ASN_COUNTER ifInUnknownProtos (at 15) which is of type ASN_COUNTER ifOutOctets (at 16) which is of type ASN_COUNTER ifOutUcastPkts (at 17) which is of type ASN_COUNTER ifOutNUcastPkts (at 18) which is of type ASN_COUNTER ifOutDiscards (at 19) which is of type ASN_COUNTER ifOutErrors (at 20) which is of type ASN_COUNTER ifOutQLen (at 21) which is of type ASN_GAUGE ifSpecific (at 22) which is of type ASN_OBJECT_ID
As you can see, we can change a MIB into just about anything.
Additional reading material
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
- 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: