Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set colConfs = objWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objConf in colConfs
strAdapterName = GetAdapterName(objConf.Caption)
strIPAddress = GetMultiString_FromArray(objConf.IPAddress, ", ")
Set colNetAdapters = objWMI.ExecQuery("Select * From Win32_NetworkAdapter WHERE Caption = '" & objConf.Caption & "'")
For Each objAdapter In colNetAdapters
WScript.Echo "Adding monitor for network connection: " & objAdapter.NetConnectionID
'Bandwidth and Bytes
Column = 1
MonitorName = "Bytes+Throughput:+" & Replace(objAdapter.NetConnectionID, " ", "+")
monitorParams = "Bandwidth:Bytes+Throughput:Bytes+Throughput:3:false;"
resultParams = "BytesReceivedPerSec:Received/Sec:N%2FA:2;BytesSentPerSec:Sent/Sec:N%2FA:2;BytesTotalPerSec:Total/Sec:N%2FA:2;"
AddCustMon
'Packets/Sec
Column = 2
MonitorName = "Packets:+" & Replace(objAdapter.NetConnectionID, " ", "+")
monitorParams = "PacketsPerSec:Packets:Packets/Sec:3:false;"
resultParams = "PacketsReceivedPerSec:Received/Sec:N%2FA:2;PacketsSentPerSec:Sent/Sec:N%2FA:2;TotalPacketsPerSec:Packets/Sec:N%2FA:2;PacketsReceivedDiscarded:Discarded:N%2FA:2;PacketsReceivedError:Error:N%2FA:2;"
AddCustMon
'Make sure we add the monitor on the correct row and column
Row = Row + 1
Next
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.