Earlier I posted a blog about how to use SNMPGET to return information from any SNMP OID, or Object ID, that we were interested in retrieving information from. It was pretty easy and straight forward to pull this information. We used a utility from NETSNMP called SNMPGET.exe to get this information.

Well in that same SNMP package there is another utility called SNMPWALK.exe. Well this utility is particularly interesting because we can use it to walk an entire OID sub-key and return all of the values listed. So instead of pulling every single value individually via a loop, which can be a time consuming process because we have to negotiate security every time and re-establish our network connectivity, we can just query the whole sub key, and then parse that information client side.

So, in order to utilize this SNMPWALK.exe functionality, we’ll need another script:

The SNMPWALK function works pretty much the same way as the SNMPGET function, the only big difference is that it returns a string separated by the “|” character. You also have the option of returning the OID, that the information was returned from, in the string returned by the function. This can be particularly handy if you have a bunch of OIDs you would like to check against but don’t want the overhead of calling them all one by one via the SNMPGET function.

I wrote one more function to parse the information from the SNMPWALK function to retrieve the information you are looking for from the results of the SNMPWALK:

So there it is. I will post some sample scripts that utilize all three of these functions in an upcoming blog. The script I will post was written to pull in hard drive and controller information from Compaq and HP servers but these scripts can be used for any device that has SNMP network connectivity.

Feel free to leave comments or questions and good luck with your scripting.

One thought on “SNMPGET? How about an SNMPWALK?

Leave a Comment