TUT:Using and loading MIBS

From Net-SNMP Wiki
Revision as of 19:58, 23 January 2007 by Wes (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Using local MIBs

The net-snmp tools can translate numeric object identifies (OIDs) into textual object identifiers using the MIB description files. The net-snmp toolkit provides a few of the standard MIBs, but certainly doesn't contain all the MIBs known to man.

First off, you should know about the paths that the tools load MIBs from. By default, it loads things from the following list of directories:

  1. $HOME/.snmp/mibs
  2. /usr/local/share/snmp/mibs

So, lets say you have a MIB called | CISCO-RHINO-MIB that you want parsed (it really exists, and I particularly liked the name so I'm using it in the tutorial). Place the file in one of the above two directories. If you pulled it from another file (like an RFC), make sure it doesn't contain anything non-MIB related (like the text leading up to it, and the page separators). The very first line in the file should begin with something like "CISCO-RHINO-MIB DEFINITIONS ::= BEGIN"

Now, pick a node in the file that you want to translate that currently isn't being translated. From the CISCO-RHINO-MIB, I'll pick the ciscoLS1010ChassisFanLed node.

First, lets verify that our handy snmptranslate command (discussed <a href="snmptranslate.html">earlier</a>) doesn't yet know about this node:

 % snmptranslate -IR ciscoLS1010ChassisFanLed
 Unknown object identifier: ciscoLS1010ChassisFanLed

Nope, it doesn't. So, first we need to download the | CISCO-RHINO-MIB file and place it in a directory that our snmp tools can find it in. So, I'm going to place the file in $HOME/.snmp/mibs.

Now, lets use the -m flag to snmptranslate to tell it to load that mib. We'll use "-m +CISCO-RHINO-MIB" to indicate that we want the tool to load not only the default set of mibs, but the CISCO-RHINO-MIB as well (the leading '+' plus means "also").

% snmptranslate -m +CISCO-RHINO-MIB -IR ciscoLS1010ChassisFanLed

 Cannot find module (CISCO-SMI): At line 31 in $HOME/.snmp/mibs/CISCO-RHINO-MIB.my
 Unlinked OID in CISCO-RHINO-MIB: ciscoLS1010ChassisMIB ::= { workgroup 11 }
 Cannot adopt OID in CISCO-RHINO-MIB: ciscoAtmSwitchInvalidCellHeader ::= { ciscoAtmSwitchInvalidCellHeaderEntry 2 }
 ... rest of output truncated ...</i>

Wait a minute... What the heck is all that stuff? Errors! Well, the first line is the most important and it's telling us that we're missing the CISCO-SMI MIB as well. So, if we go | download that MIB file and place it in our $HOME/.snmp/mibs directory as well the command should suddenly work:

 % snmptranslate -m +CISCO-RHINO-MIB -IR ciscoLS1010ChassisFanLed
 .1.3.6.1.4.1.9.5.11.1.1.12

Success!

One last comment: You can also force loading of a given MIB and its node in one fell swoop (and this method is the one most highly recommended by Niels Baggesen, one of our primary core developers):

 % snmptranslate CISCO-RHINO-MIB::ciscoLS1010ChassisFanLed
 .1.3.6.1.4.1.9.5.11.1.1.12

So, there you have it. A complete example for how to get your own insert-spiffy-mib-here loaded into the net-snmp tools.


Yes, but how do I make it happen all the time?

Good question. And of course, we have multiple options for you. We support a number of ways of doing this.

Ethereal/Wireshark Notes

Note to | Ethereal users: One of these methods is how you would have to do it for Ethereal since it won't support the -m and -M options discussed above.

  • First, you can put the following lines in a snmp.conf file. This file can be placed in a system-wide location (EG, /usr/local/share/snmp.conf) or in a personal file (EG, $HOME/.snmp/snmp.conf):
 mibs +CISCO-RHINO-MIB
 mibs +SOME-OTHER-SPIFFY-MIB
  • You can also use the MIBS environment variable to specify things (example assumes a /bin/sh style shell):
 MIBS=+CISCO-RHINO-MIB:SOME-OTHER-SPIFFY-MIB
 export MIBS

Please note the following sections of the FAQ as well:

  • <a
     href="http://www.net-snmp.org/FAQ.html#How_do_I_add_a_MIB_">How
     do I add a MIB</a>
  • <a
     href="http://www.net-snmp.org/FAQ.html#How_do_I_add_a_MIB_to_the_tools_">How do I add a MIB to the tools?</a>
   href="http://www.net-snmp.org/FAQ.html">FAQ</a> Please!)

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.

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!

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.

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.

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:

Operating System Specific Tutorials