검색결과 리스트
글
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
다음 코드는, 2초 간격으로 네트워크 인터페이스를 통해서 발생하는 트래픽을 모니터링 하는 코드이다.
Windows Server 2003 및 XP에 서만 체크가 가능하다.
Windows Server 2003 및 XP에 서만 체크가 가능하다.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
(objWMIService, "Win32_PerfFormattedData_TCPIP_NetworkInterface").objectSet
objRefresher.Refresh
For i = 1 to 5
For Each objItem in colItems
Wscript.Echo "Bytes Received Per Second: " & _
objItem.BytesReceivedPersec
Wscript.Echo "Bytes Sent Per Second: " & objItem.BytesSentPersec
Wscript.Echo "Bytes Total Per Second: " & objItem.BytesTotalPersec
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Current Bandwidth: " & objItem.CurrentBandwidth
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Output Queue Length: " & objItem.OutputQueueLength
Wscript.Echo "Packets Outbound Discarded: " & _
objItem.PacketsOutboundDiscarded
Wscript.Echo "Packets Outbound Errors: " & _
objItem.PacketsOutboundErrors
Wscript.Echo "Packets Per Second: " & objItem.PacketsPersec
Wscript.Echo "Packets Received Discarded: " & _
objItem.PacketsReceivedDiscarded
Wscript.Echo "Packets Received Errors: " & _
objItem.PacketsReceivedErrors
Wscript.Echo "Packets Received Non-Unicast Per Second: " & _
objItem.PacketsReceivedNonUnicastPersec
Wscript.Echo "Packets Received Per Second: " & _
objItem.PacketsReceivedPersec
Wscript.Echo "Packets Received Unicast Per Second: " & _
objItem.PacketsReceivedUnicastPersec
Wscript.Echo "Packets Received Unknown: " & _
objItem.PacketsReceivedUnknown
Wscript.Echo "Packets Sent Non-Unicast Per Second: " & _
objItem.PacketsSentNonUnicastPersec
Wscript.Echo "Packets Sent Per Second: " & objItem.PacketsSentPersec
Wscript.Echo "Packets Sent Unicast Per Second: " & _
objItem.PacketsSentUnicastPersec
Wscript.Sleep 2000
objRefresher.Refresh
Next
Next
만약 Windows 2000 환경이라면,
다음과 같이 성능카운터의 원시데이터를 이용해서 계산을 해줘야 한다.
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
(objWMIService, "Win32_PerfFormattedData_TCPIP_NetworkInterface").objectSet
objRefresher.Refresh
For i = 1 to 5
For Each objItem in colItems
Wscript.Echo "Bytes Received Per Second: " & _
objItem.BytesReceivedPersec
Wscript.Echo "Bytes Sent Per Second: " & objItem.BytesSentPersec
Wscript.Echo "Bytes Total Per Second: " & objItem.BytesTotalPersec
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Current Bandwidth: " & objItem.CurrentBandwidth
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Output Queue Length: " & objItem.OutputQueueLength
Wscript.Echo "Packets Outbound Discarded: " & _
objItem.PacketsOutboundDiscarded
Wscript.Echo "Packets Outbound Errors: " & _
objItem.PacketsOutboundErrors
Wscript.Echo "Packets Per Second: " & objItem.PacketsPersec
Wscript.Echo "Packets Received Discarded: " & _
objItem.PacketsReceivedDiscarded
Wscript.Echo "Packets Received Errors: " & _
objItem.PacketsReceivedErrors
Wscript.Echo "Packets Received Non-Unicast Per Second: " & _
objItem.PacketsReceivedNonUnicastPersec
Wscript.Echo "Packets Received Per Second: " & _
objItem.PacketsReceivedPersec
Wscript.Echo "Packets Received Unicast Per Second: " & _
objItem.PacketsReceivedUnicastPersec
Wscript.Echo "Packets Received Unknown: " & _
objItem.PacketsReceivedUnknown
Wscript.Echo "Packets Sent Non-Unicast Per Second: " & _
objItem.PacketsSentNonUnicastPersec
Wscript.Echo "Packets Sent Per Second: " & objItem.PacketsSentPersec
Wscript.Echo "Packets Sent Unicast Per Second: " & _
objItem.PacketsSentUnicastPersec
Wscript.Sleep 2000
objRefresher.Refresh
Next
Next
만약 Windows 2000 환경이라면,
다음과 같이 성능카운터의 원시데이터를 이용해서 계산을 해줘야 한다.
NetworkCardName = "3Com EtherLink XL 10_100 PCI For Complete PC Management NIC [3C905C-TX]"
'카드 이름에서, ()문자열은 []로 변경해야하며, / 문자는 _ 로 변경해야 함.
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface WHERE Name = '"& NetworkCardName &"'")
For Each objItem In colItems
'WScript.Echo "BytesSentPersec: " & objItem.BytesSentPersec
D1 = objItem.BytesSentPersec
Next
WScript.Sleep(1000)
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface WHERE Name = '"& NetworkCardName &"'")
For Each objItem In colItems
'WScript.Echo "BytesSentPersec: " & objItem.BytesSentPersec
D2 = objItem.BytesSentPersec
Next
WScript.Echo "Total Bytes/s=" & D2-D1
출처 : http://www.wssplex.net/TipnTech.aspx?Seq=220
'카드 이름에서, ()문자열은 []로 변경해야하며, / 문자는 _ 로 변경해야 함.
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface WHERE Name = '"& NetworkCardName &"'")
For Each objItem In colItems
'WScript.Echo "BytesSentPersec: " & objItem.BytesSentPersec
D1 = objItem.BytesSentPersec
Next
WScript.Sleep(1000)
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface WHERE Name = '"& NetworkCardName &"'")
For Each objItem In colItems
'WScript.Echo "BytesSentPersec: " & objItem.BytesSentPersec
D2 = objItem.BytesSentPersec
Next
WScript.Echo "Total Bytes/s=" & D2-D1
출처 : http://www.wssplex.net/TipnTech.aspx?Seq=220
'프로그래밍' 카테고리의 다른 글
DHCP Relay Agent - How Relay Agent Work (0) | 2011.02.18 |
---|---|
배치파일로 대량 부하 테스트 (0) | 2010.11.23 |
How many simultaneous sockets can I have open? (0) | 2010.08.04 |
MaxUserPort 최대값 변경 (0) | 2010.08.02 |
TCP TIME-WAIT 상태 이해하기 (0) | 2009.11.23 |
RECENT COMMENT