windows 호스트 네트워크 인터페이스 이 용 률 을 측정 하 는 vbs 코드
5446 단어 네트워크 인터페이스활용 도감시 하 다
' : btlwchk_netinterface.vbs
' : Copyright (c) 2011 guangzhou bluetech technology Incorporated.All rights reserved
' : windows
' : 2011-09-1
' : zhangkai
' : vbs
'
MonSubject="NetInterface"
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
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface",,48)
Dim BytesTotalPersec1(20),TimeValue1(20),Name1(20),CurrentBandwidth(20),BytesReceivedPerSec1(20),BytesSentPerSec1(20),PacketsReceivedPerSec1(20),PacketsSentPerSec1(20),_
BytesTotalPersec(20),PercentNetwork(20),BytesReceivedPerSec(20),BytesSentPerSec(20),PacketsReceivedPerSec(20),PacketsSentPerSec(20)
n=0
For Each objItem in colItems
Name1(n) = objItem.Name
BytesTotalPersec1(n) = objItem.BytesTotalPersec
BytesReceivedPerSec1(n) = objItem.BytesReceivedPerSec
BytesSentPerSec1(n) = objItem.BytesSentPerSec
PacketsReceivedPerSec1(n) = objItem.PacketsReceivedPerSec
PacketsSentPerSec1(n) = objItem.PacketsSentPerSec
TimeValue1(n) = objItem.Timestamp_PerfTime
CurrentBandwidth(n) = objItem.CurrentBandwidth
TimeBase = objItem.Frequency_PerfTime
n=n+1
Next
' 2
WScript.Sleep 1000
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface",,48)
Dim BytesTotalPersec2(20),TimeValue2(20),Name2(20),BytesReceivedPerSec2(20),BytesSentPerSec2(20),PacketsReceivedPerSec2(20),PacketsSentPerSec2(20)
k=0
For Each objItem in colItems
Name2(k) = objItem.Name
BytesTotalPersec2(k) = objItem.BytesTotalPersec
BytesReceivedPerSec2(k) = objItem.BytesReceivedPerSec
BytesSentPerSec2(k) = objItem.BytesSentPerSec
PacketsReceivedPerSec2(k) = objItem.PacketsReceivedPerSec
PacketsSentPerSec2(k) = objItem.PacketsSentPerSec
TimeValue2(k) = objItem.Timestamp_PerfTime
k=k+1
Next
j=0
For i=0 to n-1
If TimeValue2(j) - TimeValue1(j) = 0 Then
strnetwork = "BytesTotalPersec=0"
Else
' = (BytesReceivedPerSec + BytesSentPerSec)*8*100/ CurrentBandwidth
'
BytesTotalPersec(j) = (BytesTotalPersec2(j) - BytesTotalPersec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PercentNetwork(j) = BytesTotalPersec(j)*8*100 / CurrentBandwidth(j)
PercentNetwork(j) = round(PercentNetwork(j),2)
' BytesReceivedPerSec
BytesReceivedPerSec(j) = (BytesReceivedPerSec2(j) - BytesReceivedPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)/1024
BytesReceivedPerSec(j) = round(BytesReceivedPerSec(j),2)
' BytesSentPerSec
BytesSentPerSec(j) = (BytesSentPerSec2(j) - BytesSentPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)/1024
BytesSentPerSec(j) = round(BytesSentPerSec(j),2)
' PacketsReceivedPerSec
PacketsReceivedPerSec(j) = (PacketsReceivedPerSec2(j) - PacketsReceivedPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PacketsReceivedPerSec(j) = round(PacketsReceivedPerSec(j),2)
' PacketsSentPerSec
PacketsSentPerSec(j) = (PacketsSentPerSec2(j) - PacketsSentPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PacketsSentPerSec(j) = round(PacketsSentPerSec(j),2)
' CurrentBandwidth
CurrentBandwidth(j) = CInt(CurrentBandwidth(j)/1000/1000)
End If
If j = 0 Then
Wscript.Echo MonSubject & " 0:OK|Name=" & Name1(j) & ",PercentNetwork=" & PercentNetwork(j) & ",BytesReceivedPerSec=" & BytesReceivedPerSec(j) & ",BytesSentPerSec=" & BytesSentPerSec(j) _
& ",PacketsReceivedPerSec=" & PacketsReceivedPerSec(j) & ",PacketsSentPerSec=" & PacketsSentPerSec(j) & ",CurrentBandwidth=" & CurrentBandwidth(j)
End If
'Wscript.Echo MonSubject & " 0:OK|" & Name1(j) & ",PercentNetwork=" & PercentNetwork
j=j+1
Next
이 문장 은 여기까지 소개 되 었 다
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
디스크 IO 이 용 률 모니터링 VBS 스 크 립 트(windows)핵심 코드 WMI 를 사 용 했 습 니 다.필요 하신 분 들 은 참고 하 셔 도 됩 니 다....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.