14.13. Finding and Testing MIBs and OIDs

All of this MIB and OID stuff is a bit mysterious. How do you find them? How do you know what to use? How do you verify that you have the correct ones?

When you see an error like this from starting MRTG:

	# env LANG=C mrtg /etc/mrtg.cfg
	SNMP Error:
	Received SNMP response with error code
	  error status: noSuchName
	  index 2 (OID: 1.3.6.1.4.1.2021.9.1.9.3)
	[...]

It means either the OID does not exist, or you did not enter the correct file for the LoadMIBs option in mrtg.cfg. The first thing to do is query the numerical OID:

	$ snmpwalk -v 1 -c password localhost 1.3.6.1.4.1.2021.9.1.9.3
	UCD-SNMP-MIB::dskPercent.3 = INTEGER: 22

This shows that you have the correct OID, so you need to correct your LoadMIBs entry. snmpwalk shows you the correct MIBs file. If you don't know what directory your MIBs files are in, the locate command will tell you:

	$ locate UCD-SNMP-MIB
	/usr/share/snmp/mibs/UCD-SNMP-MIB.txt

So, LoadMIBs needs to look like this:

	LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt

Then, rerun mrtg, and you're in business.

This command lists all OIDs on your system:

	$ snmpwalk -v 1 -c password localhost

There are thousands of them:

	$ snmpwalk -v 1 -c password localhost | wc -l
	1824

system is actually a symbolic name; the real OID name is a number that you can see with the -On option:

	$ snmpwalk -On -v 1 -c password localhost system
	.1.3.6.1.2.1.1.1.0 = STRING: Linux xena 2.6.20-16-generic #2 SMP Thu Jun 7 20:19:32
	UTC 2007 i686
	.1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.8072.3.2.10
	[...]

So, .1.3.6.1.2.1.1 is the same as system, and it has a hierarchy of OIDs under it.

These two commands are the same:

	$ snmpwalk -v 1 -c password localhost system
	$ snmpwalk -v 1 -c password localhost .1.3.6.1.2.1.1

It's more common with commercial routers to use the OIDs in your MRTG configuration, rather than having the luxury of a symbolic name.

How do you find out which ones you want in the first place? This is more complicated. You can dig up OIDs for some trial-and-error testing with the usual Linux search tools:

	$ grep -ir tcp /usr/share/snmp/mibs/
	/usr/share/snmp/mibs/TCP-MIB.txt:TCP-MIB DEFINITIONS ::= BEGIN
	/usr/share/snmp/mibs/TCP-MIB.txt:tcpMIB MODULE-IDENTITY
	/usr/share/snmp/mibs/TCP-MIB.txt: "The MIB module for managing TCP implementations.
	/usr/share/snmp/mibs/TCP-MIB.txt:-- the TCP base variables group
	[...]

You're probably better off looking for documentation specific to the devices and services you want to monitor, especially commercial routers such as Cisco, Juniper, NetGear, and so forth. In an ideal world, all vendors would make complete information available, and many vendors are good at keeping up-to-date information and helpful documentation on their web sites.

If you can't get what you need from the vendor, try these sites:

Alvestrand (http://www.alvestrand.no/objectid/)

Everything you could ever want to know about MIBs and OIDs is here.

MIB Depot (http://www.mibdepot.com/index.shtml)

This site is a good resource for vendor-specific information.