MRTG &Network Monitoring &Scripting &Servers &SNMP Jl. on 16 Mar 2009 09:37 pm
SNMP (MRTG) – How to find your OIDs, MIBs, and everything else.
Back with the MRTG and SNMP series, I spent a good number of hours trying to get otherwise-working configurations to work on my server with rare success. Every once in a while, I’d get a completely different value than what I expected, and other times I’d get no value whatsoever because that OID couldn’t be found, even though it worked on another (live!) config! This will be an overview about how to find the OID value you’re looking for, specifically Hard Drives and Memory.
I’m going to presume you’ve already become vaguely familiar with what SNMP is as a concept, you’ve installed the Windows SNMP server, and you’ve configured a community name and set allowed hosts. If you haven’t, start here.
Once you have the basics done, get a copy of SNMPUtil.exe . If you have a Windows NT4 cd laying around, how handy. If not, go here and get it. Note: That site also has an app called SNMP-Informant available. I’ve heard it simplifies things considerably, but I’m not using it at present, I like the pain. Once you’ve downloaded SNMPUtil, move the .exe to your windowssystem32 directory that way you can use it from a command line without specifying a full path.
[ For those still wondering, the windowssystem32 directory is already in the “Path” portion of your Environmental Variables, which means we can call a program in the dir from anywhere. While we could have added whatever directory you placed snmputil.exe in to the Path variable, my way was easier. Google Environmental Variables for more help. ]
Once you have snmputil placed, open a command prompt and run it with no flags/arguments. You should get a response like:
c:SNMP>snmputil
Error: Incorrect number of arguments specified.usage: snmputil [get|getnext|walk] agent community oid [oid ...]
snmputil trapc:SNMP>
That tells us that there are three options – get, getnext, and walk – when we’re using the app. The rest of the arguments are agent (which is the device/server you’re trying to poll, in my case localhost or 127.0.0.1), community (uhh… Google.) and oid which is the number found in a MIB.
Quick explanation: A MIB is a “database” (big text file) with individual OIDs in them. An OID is a specific resource with a value. So if I’m looking for an OID that will poll my Windows Server’s Processor utilization, I want the Windows NT Performance MIB (http://www.mibdepot.com/cgi-bin/vendor_index.cgi?r=microsoft&id=144151), and the corresponding OID.
Back to SNMPUtil…
Those arguments (get, getnext, walk) will do three related but different things. Get will get the value from a specific OID (such as “total hard disk space”). getnext will get the NEXT OID in line (don’t worry about this yet). And walk will follow a an OID tree to show you every value you can get.
Now the configuration sections that I found and used (such as from snmpboy.msft.net) referenced specific OIDs. What I’ve discovered: NOT ALL OIDS ARE THE SAME FROM SYSTEM TO SYSTEM. Let me make that perfectly clear, because nowhere did I find this written, and it’s taken me days to suss out. An OID that polls Virtual Memory for one system will NOT be the same OID on another! The same holds true for drives. Where the config demonstrated may find free space on drive C, that same OID for you could be polling drive A, B, D, or anything else.
So how do we find the OIDs for our specific system?
I’m going to introduce the rather disturbingly simple hierarchy that is in place with SNMP. The OID we’re going to start with is .1.3.6.1.2.1.25.2.3.1.3 . This is not a final value (such as “total hard disk space”, but one branch in a tree (such as: “storage resources”). These examples will assume you’re using an SNMP Server from your local machine, and your community string is public – Substitute Accordingly. From your console, type (all one line):
c:SNMP>snmputil walk 127.0.0.1 public .1.3.6.1.2.1.25.2.3.1.3
which, if your system is anywhere like mine, will return something similar to:
Variable = host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr.1
Value = String A:Variable = host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr.2
Value = String C: Label: Serial Number 2053422Variable = host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr.3
Value = String D: Label:Data Serial Number c9d83a42Variable = host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr.4
Value = String E:Variable = host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr.5
Value = String F:Variable = host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr.6
Value = String G: Label:FileDump Serial Number 0dc359f2Variable = host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr.7
Value = String Virtual MemoryVariable = host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr.8
Value = String Physical MemoryEnd of MIB subtree.
c:SNMP>
Now at first glance, these results might be somewhat confusing. They were to me. Here’s the down and dirty:
That OIB we entered (.1.3.6.1.2.1.25.2.3.1.3) was the “Host Storage Description” tree/branch. The values underneath it pull the descriptions of storage objects that SNMP is mapping. In my case, .1 goes to my floppy, .2 to my C: drive, .3 to my D: drive, etc. This also includes .7 for Virtual Memory, and .8 for Physical Memory. (Remember that). Do yourself a favor and copy and paste those results into a text file for easy viewing and reference.
What we’ll do with these will be in the next post.
Last 5 posts by Jl.
- Viewing IE and Mozilla/Firefox history from Profile Directories - November 9th, 2010
- Configure an Aironet 1200 (1231) for WPA-PSK - November 7th, 2010
- The FBD Link To The Following DIMM Failed To Train - March 26th, 2010
- Calculating flops per second per core, from Gigaflops - January 28th, 2010
- Barracuda SNMP MIBs - January 11th, 2010
on 29 Jan 2012 at 4.51 am 1.Daniel said …
Thank you for your article! I really liked seen this.
I`m look similar article on http://www.webserverdb.com/simple-network-management-protocol-snmp/