Gathering historical network statistics under Virtual Server

A little while ago I showed you how to gather information about how much traffic a virtual network had experienced in total. However it is also possible to get information about the traffic that has specifically occurred in the last minute. This script below will go through each virtual network on a physical computer and enumerate the amount of traffic seen each second for the last 60 seconds:

Set vs = CreateObject("VirtualServer.Application")

For Each vn in vs.VirtualNetworks
Wscript.Echo
Wscript.Echo "Virtual Network: " & vn.name

    Wscript.Echo
Wscript.Echo "Packets sent history: "
For Each stat in vn.PacketsSentHistory
Wscript.StdOut.Write stat
Wscript.StdOut.Write ","
Next

    Wscript.Echo
Wscript.Echo "Packets received history: "
For Each stat in vn.PacketsReceivedHistory
Wscript.StdOut.Write stat
Wscript.StdOut.Write ","
Next
Wscript.Echo
Next

Cheers,
Ben