' ' prwalker - Dumps a MIB walk database ' ' -------------------------------------------------- ' Check usage & arguments ' -------------------------------------------------- Set Sout = WScript.StdOut if WScript.Arguments.Count <> 1 then Sout.WriteLine "Usage: prwalk " WScript.Quit end if WalkFile = WScript.Arguments.Item(0) ' -------------------------------------------------- ' Create and load the database into the MIB Walker ' -------------------------------------------------- Set MIBWalker = CreateObject("UnbrowseSNMP.MIBWalker") Sout.WriteLine "Created MIB Walker " ' -------------------------------------------------- ' Open the walk file specified on the command line ' -------------------------------------------------- MIBWalker.OpenWalkSession WalkFile Sout.WriteLine "Opened Walk File " & WalkFile ' -------------------------------------------------- ' Print the latest walk session ' -------------------------------------------------- Set LatestSess = MIBWalker.GetLatestWalker Sout.WriteLine "Got latest walk session" PrintWalkSess LatestSess ' -------------------------------------------------- ' Discard, we are done with it ' -------------------------------------------------- MIBWalker.Discard Sout.WriteLine "Closed walk file " & WalkFile Sub PrintWalkSess ( WalkSession ) Sout.WriteLine "Printing walk session" Set WalkResults = WalkSession.GetResults Set ResultsTree = WalkResults.GetWalkTree Sout.WriteLine "Child count = " & ResultsTree.ChildCount For J = 0 To ResultsTree.ChildCount - 1 Set WalkNode = ResultsTree.ChildByIdx(J) If WalkNode.WNodeType = 0 Then PrintScalarVarbind (WalkNode) End If If WalkNode.WNodeType = 2 Then PrintTableVarbind (WalkNode) End If Next End Sub Sub PrintScalarVarbind ( WalkNode ) If WalkNode.HasScalarVarbind Then Set Varb = WalkNode.ScalarVarbind Sout.WriteLine "OID = " & Varb.OID & " Val = " & Varb.Value End If End Sub Sub PrintTableVarbind ( WalkNode ) Sout.WriteLine "Printing Table " & WalkNode.OIDName Sout.WriteLine "---------------------------------------" Set TableEntry = WalkNode.FirstChild Sout.WriteLine "Table Entry " & TableEntry.OIDName For I = 0 To TableEntry.ChildCount-1 Set Leaf = TableEntry.ChildByIdx (I) For K = 0 To Leaf.TableVarbindCount-1 Set Varb = Leaf.TableVarbindByIdx (K) Sout.WriteLine "OID = " & Varb.OID & " Val = " & Varb.Value Next Next Sout.WriteLine "---------------------------------------" End Sub