Monthly Archives: July 2012

Finally, a first post

I’ve been thinking about what a good first post would be, and I’ve been busy, and then I realized a week or two has gone by since I set this up.  Then I remembered my no frills philosophy.  Hopefully the syntax highlighting will work.

We have a cluster with about 45 hosts that was going to end up with 60 hosts.  Each blade chassis holds 4 blades, so one of the guys had the idea to break it into 4 clusters of 15 hosts each.  In each chassis the blade in slot 1 would be in cluster 1, slot 2 in cluster 2, and so on.  Of course, now when we’re deploying new VMs we needed to know which cluster had the least load.  This is the quickie report to show the least loaded cluster.  I don’t normally use write-host, but it was the quickest way to get the data.  Later I could integrate this into our VM deployment if it seems worthwhile.

How I used it (up arrow and enter to run it again):

write-host`nCluster`t        # Hosts`tCpuUsageMhz`tMemoryUsageMB`t# VMs`n—————`t——-`t———–`t————-`t—–; get-cluster cluster* | sort | % { $x=get-vmhost-location$_ | measure-Property cpuusagemhz,memoryusagemb -average; write-host$($_.Name)`t  $($x[0].Count)`t  $([int]$x[0].Average)`t`t  $([int]$x[1].Average)`t$((Get-VM -Location $_).Count) }

Readable version:

write-host`nCluster`t        # Hosts`tCpuUsageMhz`tMemoryUsageMB`t# VMs`n—————`t——-`t———–`t————-`t—–get-cluster cluster* | sort | % { 
    $x=get-vmhost-location$_ | measure-Property cpuusagemhz,memoryusagemb -averagewrite-host$($_.Name)`t  $($x[0].Count)`t  $([int]$x[0].Average)`t`t  $([int]$x[1].Average)`t$((Get-VM -Location $_).Count)
}