Welcome to MSDN Blogs Sign in | Join | Help

Virtual Network Statistics from WMI

Continuing with my journey through the undocumented lands of Virtual Server WMI we come to virtual network statistics.  This nice little script displays information about virtual network name, and the number of packets and bytes that have been sent received and dropped on each virtual network:

Option Explicit

Dim vsWMI, vns, vn

Set vsWMI = GetObject("winmgmts:\\.\root\vm\virtualserver")
Set vns = vsWMI.ExecQuery( "SELECT * FROM VirtualNetwork",,48)
For Each vn in vns
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Virtual Network: " & vn.Name
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Packets Sent: " & vn.PacketsSent & _
   " (" & vn.BytesSent & " bytes)"
    Wscript.Echo "Packets Received: " & vn.PacketsReceived & _
   " (" & vn.BytesReceived & " bytes)"
    Wscript.Echo "Packets Dropped: " & vn.PacketsDropped & _
   " (" & vn.BytesDropped & " bytes)"
Next

One oddity about the WMI interface here is that you will only see information about virtual network for which there is a currently running virtual machine connected.

Cheers,
Ben

Published Thursday, September 28, 2006 11:43 AM by Virtual PC Guy

Comments

No Comments
New Comments to this post are disabled
 
Page view tracker