Using SNMPGET and SNMPWALK VBScript functions to pull SNMP data from CIM
I posted the SNMPGET and SNMPWALK functions a few days ago. Now we will put those functions to use in a script that we can use to pull SNMP data from SNMP enabled devices on the network. In this script I'll be pulling the array controller information from the SNMP data populated by Compaq Insight Manager (now Server Insight Manager). But this works just as well for any SNMP capable network device. We just need some software that can browse the OID tree's that are currently populated by our SNMP enabled network device. The software I use to do that is iReasoning's MIB Browser.
But, before we can use the MIB browser to browse through the information populated in the SNMP tree, we should first understand what, exactly, MIBs are. MIB stands for Management Information Base. Basically, what MIBs do is translate an SNMP OID into a more readable name. So instead of getting an OID location like ".1.3.6.1.4.1.232.3.2.2.1.1.1" you get something like "iso(1). org(3). dod(6). internet(1). private(4). enterprises(1). compaq(232). cpqDriveArray(3). cpqDaComponent(2). cpqDaCntlrPerf(7) ". I wouldn't call this incredibly informative, but it's better than the numeric format.
Back on track now, what I am interested in are the OIDs that are populated by the Compaq Insight Manager agents running on all of my servers. I happen to know that all of HP & Compaq's MIBs are stored on their SmartStart cd's. So downloading them and searching their contents for "*.mib" reveals more than a few MIB files that will work great with iReasoning's MIB Browser.
After some searching, I figured out that all of the array controller information was stored in the OID that I mentioned above: ".1.3.6.1.4.1.232.3.2.2.1.1.1". And all of the drive information, including hard drive sizes are stored under each of the array controller OIDs, in OIDs of their own. So let's get to work writing a script that will extract all of this information from our servers:
Add in the SNMPWALK and SNMPGET functions to the end of this script and save the whole thing as a ".vbs" and you're good to go to query physical hard drive sizes from Compaq and HP servers running almost any version of CIM.
But, before we can use the MIB browser to browse through the information populated in the SNMP tree, we should first understand what, exactly, MIBs are. MIB stands for Management Information Base. Basically, what MIBs do is translate an SNMP OID into a more readable name. So instead of getting an OID location like ".1.3.6.1.4.1.232.3.2.2.1.1.1" you get something like "iso(1). org(3). dod(6). internet(1). private(4). enterprises(1). compaq(232). cpqDriveArray(3). cpqDaComponent(2). cpqDaCntlrPerf(7) ". I wouldn't call this incredibly informative, but it's better than the numeric format.
Back on track now, what I am interested in are the OIDs that are populated by the Compaq Insight Manager agents running on all of my servers. I happen to know that all of HP & Compaq's MIBs are stored on their SmartStart cd's. So downloading them and searching their contents for "*.mib" reveals more than a few MIB files that will work great with iReasoning's MIB Browser.
After some searching, I figured out that all of the array controller information was stored in the OID that I mentioned above: ".1.3.6.1.4.1.232.3.2.2.1.1.1". And all of the drive information, including hard drive sizes are stored under each of the array controller OIDs, in OIDs of their own. So let's get to work writing a script that will extract all of this information from our servers:
| 'This script is provided under the Creative Commons license located 'at http://creativecommons.org/licenses/by-nc/2.5/ . It may not 'be used for commercial purposes with out the expressed written consent 'of NateRice.com vServer = "SERVERNAME" vCommunityString = "YOURCONNECTIONSTRING" 'populate controllers aControllers = Split(SNMPWALK(vServer, vCommunityString, _ ".1.3.6.1.4.1.232.3.2.2.1.1.1", "0"), "|") vNumberOfControllers = UBound(aControllers) 'We're creating an array that will store data for up to '10 controllers and 100 drives on each controller. 'You can change this, if you have more. Dim aDriveSizes(10, 100) 'This script will error every time for a couple reasons. 'First is how we parse information for display. Second is 'occasionally data will not be returned from the device 'you query. On Error Resume Next vControllerNumber = -1 Do Until vControllerNumber = UBound(aControllers) 'populate controller info vControllerNumber = vControllerNumber + 1 'pull drive info for controller aSingleDriveSizes = Split(SNMPWALK(vServer, vCommunityString, _ ".1.3.6.1.4.1.232.3.2.5.1.1.45." & aControllers(vControllerNumber), "0"), _ "|") vDriveLoop = 0 For Each vSingleDriveSize In aSingleDriveSizes 'populate drive sizes for current controller aDriveSizes(vControllerNumber, vDriveLoop) = vSingleDriveSize vDriveLoop = vDriveLoop + 1 Next Loop '/////DISPLAY INFO\\\\\\ vControllerNumber = 0 For Each vController In aControllers vDisplayString = vDisplayString & "Controler Information " & _ vController & vbLF vDriveID = -1 Do Until vDriveID = 100 vDrive = aDriveSizes(vControllerNumber, vDriveID) vDriveID = vDriveID + 1 If Len(vDrive) > 0 Then vDisplayString = vDisplayString & " -- Drive " & vDriveID & " (" & _ vDrive & "MB)" & vbLF End If Loop vControllerNumber = vControllerNumber + 1 Next WScript.Echo vDisplayString |
Add in the SNMPWALK and SNMPGET functions to the end of this script and save the whole thing as a ".vbs" and you're good to go to query physical hard drive sizes from Compaq and HP servers running almost any version of CIM.
| Send this to: |

Comments
said...
[...]what great Info thank you very much to deliver such informative thing[...]
5/29/2009 1:38:29 AM
said...
This is something we can only say thanks
11/5/2009 6:50:31 PM
said...
Thanks for the info...very helpful
2/22/2010 5:16:10 PM