Looking at historic CPU utilization

I came across this neat little aspect of the Virtual Server COM interface – which would be very handy if you wanted to make your own ‘CPU history’ graph.  It is the ‘CPUUtilizationHistory’ object which contains the last 60 CPU utilization measurements for a given virtual machine.

Here is a very simple script that will print out the 60 measurements for a virtual machine (specified via a command line parameter):

Set objVS = CreateObject(“VirtualServer.Application”)
set objVM = objVS.FindVirtualMachine(WScript.Arguments(0))
Set colAccountants = objVM.Accountant
       
i = 1
For Each intCPUUtilization in colAccountants.CPUUtilizationHistory
    Wscript.Echo i & “: ” & intCPUUtilization
    i = i + 1
Next

Cheers,
Ben