~siggi-bjarnason/siggivbscript/vbscript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Option Explicit
Dim inFileObj, strLine, fso, strOut, strParts, strInFileName, strOutPath, objLogFileOut
Dim Priority, SubInt, Broadcast, Collision, Discard, iError, ErrorTraffic, QueDrop, util
Dim strSection, strType, objIntFileOut, objSysFileOut, objMatchFileOut
Dim UseBridging, GenericOI, MaxUptime, NumBridgeVia, NumBridges, RestartTrapNum, RestartTrapWindow, TestingNotification
Dim BackPlane, FreeMemory, BuffMiss, BuffUtil, MemFrag, ProcUtil, FanSpeed, RelTemp, RelVoltage, HighTemp, MaxUtil, MinAvail

Const IntFileName = "\ICIntThresholds.csv"
Const SysFileName = "\ICSysThresholds.csv"
Const LogFileName = "\ICThresholdLog.csv"
Const MatchFileName = "\ICMathItem.csv"

If WScript.Arguments.Count <> 2 Then
  WScript.Echo "Usage: " & wscript.scriptname & " infilename, outpath"
  WScript.Quit
End If

strInFileName = WScript.Arguments(0)
strOutPath = WScript.Arguments(1)
strSection = ""

Set fso = CreateObject("Scripting.FileSystemObject")
Set objLogFileOut = fso.createtextfile(strOutPath & LogFileName)
logout "Group,Type,Object,Value" '& vbcrlf
Set inFileObj = fso.opentextfile(strInFileName)
Set objSysFileOut = fso.createtextfile(strOutPath & SysFileName)
Set objIntFileOut = fso.createtextfile(strOutPath & IntFileName)
Set objMatchFileOut = fso.createtextfile(strOutPath & MatchFileName)
objIntFileOut.writeline "Group,Type,Priority,SubInt,Broadcast,Collision,Discard,Error,ErrorTraffic,QueDrop,Util"
objsysfileout.writeline "Type,Priority,UseBridging,GenericOI,MaxUptime,NumBridgeVia,NumBridges,RestartTrapNum,RestartTrapWindow,TestingNotification,BackPlane,FreeMemory,BuffMiss,BuffUtil,MemFrag,ProcUtil,FanSpeed,RelTemp,RelVoltage,HighTemp,MaxUtil,MinAvail"
objmatchfileout.writeline "Group,Type,MatchCriteria"
While not infileobj.atendofstream
	strLine = Trim(inFileObj.readline)
	strLine = replace(strLine, vbtab," ")
		If Left(strline,33) = "# Start of Configuration Group - " Then
			strSection = Mid(strline,34)
			If Len(strSection) > 20 Then
				If Left(strSection,14) = "Port Groups - " Then strsection = Mid(strSection,15)
			End If
			'logout strsection
		End If
		If strSection <> "" And strSection <> "Polling Groups" Then
			If Left(strline,6) = "config" Then
				strType = Trim(Mid(strline,7))
				'logout strSection & "," & strType
				If IsArray(strparts) Then 
					If Left(strsection,6) <> "System" Then 
						objIntFileOut.writeline strSection & "," & strType & "," & Priority & "," & SubInt & "," &  Broadcast & "," & Collision & "," & Discard & "," & iError & "," & ErrorTraffic & "," & QueDrop & "," & util
					End If
					If strSection = "System Resource Groups" Then 
						objSysFileOut.write strType & "," & Priority & "," & UseBridging & "," & GenericOI & "," & MaxUptime & "," & NumBridgeVia & "," & NumBridges & "," & RestartTrapNum & "," & RestartTrapWindow & "," & TestingNotification & ","
						objsysfileout.writeline BackPlane & "," & FreeMemory & "," & BuffMiss & "," & BuffUtil & "," & MemFrag & "," & ProcUtil & "," & FanSpeed & "," & RelTemp & "," & RelVoltage & "," & HighTemp & "," & MaxUtil & "," & MinAvail
					End If 
				End If
			End If
			If Left(strline,5) = "match" Then
				objmatchfileout.writeline strSection & "," & strType & "," & Trim(Mid(strline,6))
			End If 
			If Left(strline,5) = "param" Then
				strParts = split(strline, " ")
				logout strSection & "," & strType & "," & strparts(1)  & "," & strparts(2)
				Select Case strparts(1)
					case "Priority"
						Priority=strparts(2)
					case "AnalysisModeOfSubInterfacePerformance"
						SubInt = strparts(2)
					case "BroadcastThreshold"
						Broadcast = strparts(2)
					case "CollisionThreshold"
						Collision = strparts(2)
					case "DiscardThreshold"
						Discard = strparts(2)
					case "ErrorThreshold"
						iError = strparts(2)
					case "ErrorTrafficThreshold"
						ErrorTraffic = strparts(2)
					case "QueueDropThreshold"
						QueDrop = strparts(2)
					case "UtilizationThreshold"
						util = strparts(2)
					case "CorrelationUseBridgingMode"
						UseBridging = strparts(2)
					case "EnableGenericOIEvent"
						GenericOI = strparts(2)
					case "MaxUpTimeThreshold"
						MaxUptime = strparts(2)
					case "NumberOfBridgedViaThreshold"
						NumBridgeVia = strparts(2)
					case "NumberOfBridgesThreshold"
						NumBridges = strparts(2)
					case "RestartTrapThreshold"
						RestartTrapNum = strparts(2)
					case "RestartTrapWindow"
						RestartTrapWindow = strparts(2)
					case "TestingNotificationMode"
						TestingNotification = strparts(2)
					case "BackplaneUtilizationThreshold"
						BackPlane = strparts(2)
					case "FreeMemoryThreshold"
						FreeMemory = strparts(2)
					case "MemoryBufferMissThreshold"
						BuffMiss = strparts(2)
					case "MemoryBufferUtilizationThreshold"
						BuffUtil = strparts(2)
					case "MemoryFragmentationThreshold"
						MemFrag = strparts(2)
					case "ProcessorUtilizationThreshold"
						ProcUtil = strparts(2)
					case "FanSpeedThreshold"
						FanSpeed = strparts(2)
					case "RelativeTemperatureThreshold"
						RelTemp = strparts(2)
					case "RelativeVoltageThreshold"
						RelVoltage = strparts(2)
					case "HighTemperatureThreshold"
						HighTemp = strparts(2)
					case "MaxUtilizationPct"
						MaxUtil = strparts(2)
					case "MinAvailableSpace"
						MinAvail = strparts(2)						
				End Select 
			End If
		End If
Wend
If strOut <> "" Then
	'wscript.echo strOut
	logout strOut
End If
inFileObj.close
strOut = ""

objLogFileOut.close
objsysfileout.close
objintfileout.close
objmatchfileout.close

Set inFileObj = Nothing
Set objSysFileOut = Nothing
Set objIntFileOut = Nothing
Set objMatchFileOut = Nothing

Set inFileObj = nothing
Set objLogFileOut = nothing
Set fso = nothing

Sub logout(strText)
	wscript.echo strText
	objLogFileOut.writeline strText
End Sub