디스크 IO 이 용 률 모니터링 VBS 스 크 립 트(windows)
' : btlwchk_DiskIO.vbs
' : Copyright (c) 2011 guangzhou bluetech technology Incorporated.All rights reserved
' : windows IO
' : 2011-08-10
' : zhangkai
' : vbs
'
MonSubject="DiskIO"
Set Args=WScript.Arguments
If (Args.Count<1) Then
Wscript.Echo MonSubject & " -1:command line error"
WScript.Quit(3)
End If
strcid=Args(0)
'
tmparr=Split(Wscript.ScriptFullName,"\",-1)
g_strworkdir=tmparr(0)
narr=UBound(tmparr,1)
For i=1 to narr-3
g_strworkdir=g_strworkdir & "\" & tmparr(i)
Next
'
set g_fileSys = createObject ("Scripting.FileSystemObject")
Sub includeFile (fSpec)
dim file, fileData
set file = g_fileSys.openTextFile (fSpec)
fileData = file.readAll ()
file.close
executeGlobal fileData
set file = nothing
end sub
includeFile g_strworkdir & "
agios\libexec\libcomm.vbs"
'
getverhelp strcid,"v1.00"," <cid>"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' 1 IO
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfDisk_LogicalDisk where name='_Total' ",,48)
For Each objItem in colItems
DiskTime1 = objItem.PercentDiskTime
BaseTime1 = objItem.PercentDiskTime_Base
DiskBytes1 = objItem.DiskBytesPerSec
DiskReadBytes1 = objItem.DiskReadBytesPerSec
DiskWriteBytes1 = objItem.DiskWriteBytesPerSec
AvgDiskTransfer1 = objItem.AvgDiskSecPerTransfer
AvgDiskTransferBase1 = objItem.AvgDiskSecPerTransfer_Base
AvgDiskRead1 = objItem.AvgDiskSecPerRead
AvgDiskReadBase1 = objItem.AvgDiskSecPerRead_Base
AvgDiskWrite1 = objItem.AvgDiskSecPerWrite
AvgDiskWriteBase1 = objItem.AvgDiskSecPerWrite_Base
TimeValue1 = objItem.Timestamp_PerfTime
TimeBase = objItem.Frequency_PerfTime
Next
' 2 IO
WScript.Sleep 1000
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfDisk_LogicalDisk where name='_Total' ",,48)
For Each objItem in colItems
DiskTime2 = objItem.PercentDiskTime
BaseTime2 = objItem.PercentDiskTime_Base
DiskBytes2 = objItem.DiskBytesPerSec
DiskReadBytes2 = objItem.DiskReadBytesPerSec
DiskWriteBytes2 = objItem.DiskWriteBytesPerSec
AvgDiskTransfer2 = objItem.AvgDiskSecPerTransfer
AvgDiskTransferBase2 = objItem.AvgDiskSecPerTransfer_Base
AvgDiskRead2 = objItem.AvgDiskSecPerRead
AvgDiskReadBase2 = objItem.AvgDiskSecPerRead_Base
AvgDiskWrite2 = objItem.AvgDiskSecPerWrite
AvgDiskWriteBase2 = objItem.AvgDiskSecPerWrite_Base
TimeValue2 = objItem.Timestamp_PerfTime
CurrentDiskQueueLength = objItem.CurrentDiskQueueLength
Next
' IO
If BaseTime2 - BaseTime1 = 0 Then
strio ="Name=_Toltal" & ",PercentDiskTime=0%"
Else
PercentDiskTime =(DiskTime2 - DiskTime1)/(BaseTime2 - BaseTime1)*100
strio = "Name=_Total" & ",PercentDiskTime=" & PercentDiskTime
End If
' Disk Bytes/sec
If TimeValue2 - TimeValue1 = 0 Then
strdiskbyte = ",DiskBytesPerSec=0"
Else
DiskBytesPerSec = (DiskBytes2 - DiskBytes1) / ( (TimeValue2 - TimeValue1) / TimeBase)
strdiskbyte = ",DiskBytesPerSec=" & DiskBytesPerSec
End If
' Disk Read Bytes/sec
If TimeValue2 - TimeValue1 = 0 Then
strdiskreadbyte = ",DiskReadBytesPerSec=0"
Else
DiskReadBytesPerSec = (DiskReadBytes2 - DiskReadBytes1) / ( (TimeValue2 - TimeValue1) / TimeBase)
strdiskreadbyte = ",DiskReadBytesPerSec=" & DiskReadBytesPerSec
End If
' Disk Write Bytes/sec
If TimeValue2 - TimeValue1 = 0 Then
strdiskwritebyte = ",DiskWriteBytesPerSec=0"
Else
DiskWriteBytesPerSec = (DiskWriteBytes2 - DiskWriteBytes1) / ( (TimeValue2 - TimeValue1) / TimeBase)
strdiskwritebyte = ",DiskWriteBytesPerSec=" & DiskWriteBytesPerSec
End If
' Avg. Disk sec/Transfer
If AvgDiskTransferBase2 - AvgDiskTransferBase1 = 0 Then
stravgdisktran = ",AvgDiskSecPerTransfer=0"
Else
AvgDiskSecPerTransfer = ((AvgDiskTransfer2 - AvgDiskTransfer1) / TimeBase) / (AvgDiskTransferBase2 - AvgDiskTransferBase1)
stravgdisktran = ",AvgDiskSecPerTransfer=" & AvgDiskSecPerTransfer
End If
' Avg. Disk sec/Read
If AvgDiskReadBase2 - AvgDiskReadBase1 = 0 Then
stravgdiskread = ",AvgDiskSecPerRead=0"
Else
AvgDiskSecPerRead = ((AvgDiskRead2 - AvgDiskRead1) / TimeBase) / (AvgDiskReadBase2 - AvgDiskReadBase1)
stravgdiskread = ",AvgDiskSecPerRead=" & AvgDiskSecPerRead
End If
' Avg. Disk sec/Write
If AvgDiskWriteBase2 - AvgDiskWriteBase1 = 0 Then
stravgdiskwrite = ",AvgDiskSecPerWrite=0"
Else
AvgDiskSecPerWrite = ((AvgDiskWrite2 - AvgDiskWrite1) / TimeBase) / (AvgDiskWriteBase2 - AvgDiskWriteBase1)
stravgdiskwrite = ",AvgDiskSecPerWrite=" & AvgDiskSecPerWrite
End If
' Current Disk Queue Length
strdisklength = ",CurrentDiskQueueLength=" & CurrentDiskQueueLength
Wscript.Echo MonSubject & " 0:OK|" & strio & strdiskbyte & strdiskreadbyte & strdiskwritebyte & stravgdisktran & stravgdiskread & stravgdiskwrite & strdisklength
WMI 를 사 용 했 습 니 다.필요 하신 분 들 은 참고 하 셔 도 됩 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
windows 호스트 네트워크 인터페이스 이 용 률 을 측정 하 는 vbs 코드btlwchk_netinterface.vbs 이 문장 은 여기까지 소개 되 었 다...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.