Check VMware CPU oversubscription with a PowerCLI Oneliner

This PowerCLI oneliner will give you quick insight in the capacity of your VMware clusters by showing the oversubscription on CPU’s. The CPU Oversubscription is the ratio between the number of virtual CPU’s (vCpu) allocated to all vm’s in the cluster to the number of physical processor cores of the hosts in the cluster.

If this value is too high (2 = conservative, 6 = agressive), your virtual machines might experience performance degradation due to cpu contention. You can check the CPU Ready % to determine whether you have CPU Contention Issues (5-10% is the threshold).

#Connect to vCenter
Connect-VIServer yourvcenterservernamehere
#NOTE: the last 2 is the number of digits to round to. The other 2 is there to account for hyperthreading and should be set to 1 if you do not use hyperthreading
Get-Cluster | Sort name | Select Name, @{N="CpuOversubscriptionFactor";E={[math]::Round((($_|get-VM|measure numcpu -sum).Sum)/(($_|get-vmhost|measure numcpu -sum).sum)/2,2)}}
Disconnect-VIServer * -Confirm:$false

Leave a Reply