PS Script to Convert SNMP Walk Strings in SCOM 2012 to Human-Readable form

I have put together a quick and dirty powershell script that will convert all HEX values from an SNMP Walk in SCOM 2012 .  It can be optimized, but as is, it runs pretty fast and clean.

If you want to dump all of the SNMP OIDs from a discovered device in SCOM 2012, you can click the network device and run the task for an SNMP Walk.  The problem is, once you open up the txt file and look through it, all of the Strings are in HEX.  The same goes with the IP Addresses.  I decided to write a powershell script to convert all of the strings and IP Address values that were HEX to actual readable strings and IP Addresses.

Here is how it works.  From powershell, run the script with a single parameter.  It is the text file created when you ran the SCOM task and dumped the OIDs and values from the device.  Use this as the single parameter for the script.  It will generate an output file to the same folder as the input file parameter.  It appends “.cleaned.txt” to the end of the file.

Here is a quick example of the before and after.

 

BEFORE:

.1.3.6.1.2.1.1.1.0 OCTET-STRING 436973636F204E582D4F5328746D29206E353030302C20536F66747761726520286E353030302D756B39292C2056657273696F6E20352E322831294E31283261292C2052454C4541534520534F46545741524520436F707972696768742028632920323030322D3230313120627920436973636F2053797374656D732C20496E632E20446576696365204D616E616765722056657273696F6E20362E312831292C2020436F6D70696C65642031302F32312F323031322032313A30303A3030
.1.3.6.1.2.1.1.2.0 OBJ-ID .1.3.6.1.4.1.9.12.3.1.3.1084
.1.3.6.1.2.1.1.3.0 TIME-TICKS 203803302
.1.3.6.1.2.1.1.4.0 OCTET-STRING 77686F407768657265
.1.3.6.1.2.1.1.5.0 OCTET-STRING
.1.3.6.1.2.1.1.6.0 OCTET-STRING 736E6D706C6F636174696F6E
.1.3.6.1.2.1.1.7.0 INTEGER-32 70
.1.3.6.1.2.1.1.8.0 TIME-TICKS 4294959824

 

AFTER

.1.3.6.1.2.1.1.1.0 OCTET-STRING Cisco NX-OS(tm) n5000, Software (n5000-uk9), Version 5.2(1)N1(2a), RELEASE SOFTWARE Copyright (c) 2002-2011 by Cisco Systems, Inc. Device Manager Version 6.1(1),  Compiled 10/21/2012 21:00:00
.1.3.6.1.2.1.1.2.0 OBJ-ID .1.3.6.1.4.1.9.12.3.1.3.1084
.1.3.6.1.2.1.1.3.0 TIME-TICKS 203803302
.1.3.6.1.2.1.1.4.0 OCTET-STRING who@where
.1.3.6.1.2.1.1.5.0 OCTET-STRING
.1.3.6.1.2.1.1.6.0 OCTET-STRING snmplocation
.1.3.6.1.2.1.1.7.0 INTEGER-32 70
.1.3.6.1.2.1.1.8.0 TIME-TICKS 4294959824

There is a one small caveat.  When it runs across a string type, it will convert it.  This means that there are some strings that you may not want converted, depending upon the OID.  For instance, when you have an OID that is a MAC Address, the SCOM SNMP Walk will present that as a String type.  The script will convert that from HEX to some strange string.  This is not what you want, if you want to read the actual MAC Address.  Currently, I do not see a way around this easily.  The script is not perfect, but it will convert the strings you want to read.

I usually open both text files, the original from the SCOM SNMP Walk and the new cleaned text file.  That way, I can “undecipher” to its original form, if that makes any sense.

Anyway, feel free to use it and modify it however you want.

SCOM-Convert-Walk.ps1

 

Stephen Hull
www.jaxmp.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.