' Check command line parameters
On Error Goto 0
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
'On Error Resume Next
Select Case WScript.Arguments.Count
Case 1
strComputer = Wscript.Arguments(0)
Set wbemServices = objWbemLocator.ConnectServer(strComputer,"Root\CIMV2")
Case 3
strComputer = Wscript.Arguments(0)
strUsername = Wscript.Arguments(1)
strPassword = Wscript.Arguments(2)
Set wbemServices = objWbemLocator.ConnectServer(strComputer,"Root\CIMV2",strUsername,strPassword)
Case Else
strMsg = "Error # in parameters passed"
WScript.Echo strMsg
WScript.Quit(0)
End Select
if Err.Number Then
WScript.Echo vbCrLf & "Error # " & _
" " & Err.Description
End If
On Error GoTo 0
'On Error Resume Next
Set colItems = wbemServices.ExecQuery("Select * from Win32_PerfFormattedData_PerfDisk_PhysicalDisk",,48)
if Err.Number Then
WScript.Echo vbCrLf & "Error # " & _
" " & Err.Description
End If
On Error GoTo 0
For Each objItem in colItems
strMsg = RemoveWhiteSpace(objItem.Name) & vbTab
If (objItem.Name <> "_Total") Then
strMsg = Mid(strMsg, 2)
End If
strMsg = strMsg & objItem.CurrentDiskQueueLength
WScript.Echo strMsg
Next
Function RemoveWhiteSpace(strText)
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "\s+"
RegEx.Multiline = True
RegEx.Global = True
strText = RegEx.Replace(strText,"")
RemoveWhiteSpace = strText
End Function
<DEFAULTGRAPH Name="DiskQueueLength">
<YAXISTEXT>Queue Length</YAXISTEXT>
<DISPLAYNAME>WMI Disk Queue Length</DISPLAYNAME>
<name>DiskQueueLength</name>
<Vendor>WMI</Vendor>
<Description>Monitors Disk Queue Length</Description>
<oid>DiskQueueLength</oid>
<Provider>WMI</Provider>
<Monitor>Resource</Monitor>
<type>multiple</type>
<interval>300</interval>
<THRESHOLDENABLED>false</THRESHOLDENABLED>
</DEFAULTGRAPH>
<CATEGORY ID="DiskQueueLength" command="diskqlen.vbs" parseAll="true" ignoreLines="2" description="WMI Disk Queue Length">
<ENTITY ID="CurrentQueueLength" storeValue="curValue" storeHistory="true" units="length">
<PARSE token="2" name="curValue"/>
</ENTITY>
</CATEGORY>