Difference between revisions of "TUT:Using and loading MIBS"

From Net-SNMP Wiki
Jump to: navigation, search
m (minor edit)
Line 135: Line 135:
 
* [http://www.moralesvsmaidana.co.cc/2011/02/morales-vs-maidana-live-streaming/ morales vs maidana live streaming]
 
* [http://www.moralesvsmaidana.co.cc/2011/02/morales-vs-maidana-live-streaming/ morales vs maidana live streaming]
 
* [http://digital-printers.blogspot.com digital printers]
 
* [http://digital-printers.blogspot.com digital printers]
 
+
* [http://www.iwanttosellmydiamond.net  sell a diamond]
 +
* [http://www.pacquiaomosley.co.cc pacquiao vs mosley]
 +
* [http://www.antiqueszaar.com/ antique]
 
* ... (Read the entire [http://www.net-snmp.org/FAQ.html FAQ] Please!)
 
* ... (Read the entire [http://www.net-snmp.org/FAQ.html FAQ] Please!)
 
* [[Writing your own MIBs]]
 
* [[Writing your own MIBs]]
  
 
{{TUT:LIST}}
 
{{TUT:LIST}}

Revision as of 13:30, 5 April 2011

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

Note that many distributions change the default paths. To find out which directories are used on your system, run the following command:

net-snmp-config --default-mibdirs

(if that doesn't work because your distribution didn't repackage net-snmp-config you can use this instead:)

snmptranslate -Dinit_mib .1.3 2>&1 |grep MIBDIR

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", and the very last line of the file should be "END"

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 snmptranslate) doesn't yet know about this node:

 % snmptranslate -IR -On 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 -On 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 -On 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 -On 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.


  • First, you can put the following lines in a snmp.conf file. This file can be placed in the system-wide configuration location (EG, /usr/local/share/snmp.conf) or in a personal file (EG, $HOME/.snmp/snmp.conf). The system-wide configuration file location will depend on how Net-SNMP was built on your system. Run net-snmp-config --snmpconfpath to display the list of paths.
 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
  • For the brave you can load all MIB files in your system-wide location - This can save you time, but may give you errors as shown below.

To snmp.conf:

 mibs +ALL

And to run it:

 % snmpwalk -v2c public 192.168.1.100
 Warning: Module MAU-MIB was in /usr/share/snmp/mibs//DOT3-MAU-MIB.txt now is /usr/share/snmp/mibs//RFC2668-MIB.txt
 Warning: Module DISMAN-EVENT-MIB was in /usr/share/snmp/mibs//EVENT-MIB.txt now is /usr/share/snmp/mibs//DISMAN-EVENT-MIB.txt
 Warning: Module P-BRIDGE-MIB was in /usr/share/snmp/mibs//P-BRIDGE-MIB.txt now is /usr/share/snmp/mibs//P-BRIDGE.txt

Although, with enabling so many SNMP MIBs at once comes a consequence as seen above. Pipe the stderr to null for cleaner output.

 % snmpwalk -v2c public 192.168.1.100 2>/dev/null
 SNMPv2-MIB::sysDescr.0 = STRING: Linux server1 2.4.34-pre2 #170 Fri Sep 15 20:10:21 CEST 2006 mips
 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-TC::linux
 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (706980) 1:57:49.80

Ethereal/Wireshark Notes

Note to Wireshark users (previously known as Ethereal):

You must use one of these methods in this section for Wireshark since it won't support the -m and -M options discussed previously.

See Also

Please note the following sections of the FAQ as well:

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