Getting Virtual Center “Summary” Stats With the VI Toolkit

First let me explain exactly what I’m talking about. In virtual center, when you select a host, you get a “Summary” page. On this page there are some statistics… A picture perhaps will make this easier:

2009-01-25_1346_001

Better? I think so.

So first for those resources on top:

PS C:\> get-vmhost | get-view | %{ $_.Summary.QuickStats } | fl *

OverallCpuUsage           : 874
OverallMemoryUsage        : 3162
DistributedCpuFairness    : 0
DistributedMemoryFairness : 0
DynamicType               :
DynamicProperty           :

So there are a few other things in there too, but we’re looking at the CPU & Overall Memory, Memory being shown in MB.

Next for the datastores:

PS C:\Documents and Settings\cody.bunch> get-vmhost | get-datastore | select Name, FreeSpaceMB | fl

Name        : esx:storage1
FreeSpaceMB : 39085

Name        : Local Storage
FreeSpaceMB : 170557

Easier this time. The free space again being in MB. This would be useful if you are doing periodic polling, or wanted to check available resources before provisioning a new VM.

6 thoughts on “Getting Virtual Center “Summary” Stats With the VI Toolkit

  • This is cool, but how can I get the used AND configured to more accurately mirror the picture?

  • Excellent, but can I do this for CPU / Memory too? Sorry I wasn't clear in my inital query…

    Thanks!

  • Used = Capacity – Free, agreed?
    If thats the case, we can start with:
    get-vmhost | get-datastore | select Name, CapacityMB, FreeSpaceMB | fl

    This gives you a list of the capacities & free space. So you can get used by doing:
    get-vmhost | select -first 1 | get-datastore | select -first 1 | %{ $usedMB = $_.CapacityMB – $_.FreeSpaceMB }
    $usedMB will then contain your used MB's.

    Let me know if you need further assistance.

  • This is cool, but how can I get the used AND configured to more accurately mirror the picture?

  • Excellent, but can I do this for CPU / Memory too? Sorry I wasn't clear in my inital query…

    Thanks!

  • Used = Capacity – Free, agreed?
    If thats the case, we can start with:
    get-vmhost | get-datastore | select Name, CapacityMB, FreeSpaceMB | fl

    This gives you a list of the capacities & free space. So you can get used by doing:
    get-vmhost | select -first 1 | get-datastore | select -first 1 | %{ $usedMB = $_.CapacityMB – $_.FreeSpaceMB }
    $usedMB will then contain your used MB's.

    Let me know if you need further assistance.

Comments are closed.