preloader
28 January 2013 / #Esxi #Powercli

VM/Host/Cluster load in PowerCLI

Update 2014.10.31: Following a comment requesting adding datastore usage as well, we added datastore support to this script 😄

In order to follow up our previous post about cluster load in PowerCLI, a chat with Alan Renouf convince us to add support for other vCenter objects, the basic idea was to build a universal Get-Load function that will display the load of pipelined or explicit objects, Piece Of Cake !

graph_cake

Thinking about it, what we wanted to do is quite similar as the Get-View behavior, for instance the possibility to use it like:

Get-View -ViewType VirtualMachines
Get-VM | Get-View
Get-View -ViewType HostSystem
Get-VMHost | Get-View

Thanks to the proxies commands, we looked at the Get-View cmdlet definition, for instance with the following command:

[System.Management.Automation.ProxyCommand]::create((New-Object System.Management.Automation.CommandMetaData(Get-Command Get-View)))

Our PowerCLI function will display graphical ASCII art load in console for several object types (virtual machine, ESX host or vSphere cluster). This function can be used in 2 ways, first as standalone cmdlet:

Get-Load -LoadType VirtualMachine
Get-Load -LoadType HostSystem
Get-Load -LoadType Datastore
Get-Load -LoadType ClustercomputeResource

Then you can pass objects to it through pipeline:

Get-VM "vm*" | Get-Load
Get-VMHost | Get-Load
Get-Datastore -Location "storagepod01" | Get-Load
Get-Cluster -Location "folder01" | Get-Load

Right now, there is only 4 object types supported (it’ll be remember to you if you try to think out the box :p )

get-load-invalidtype

Here are samples for ASCII art load for different objects:

get-load-vm

get-load-vmhost

get-load-datastore

The Get-Load.ps1 script is available for download in our GitHub page: https://github.com/v-team/powercli-toolbox


> Frederic MARTIN