View VMware Cluster CPU Contention Ratio

Posted: December 24, 2017 in Scripts, VMware

This has been useful for a few clients to quickly show them a table of their vCPU to Logical CPU contention ratio across their clusters. The lCPU count does include hyper-threading, but you could easily adjust the script to only use physical core count if you wanted.

Be sure to add in your own vCenter server name at the top.

You could also pipe the last command to Export-CSV if you want to use it in reports, etc.

 

Connect-VIServer “vCenterServerName”

$ClusterContentionRatio = @()$ClusterContentionRatio = @()
$Clusters = Get-ClusterForEach ($Cluster in $Clusters){
$LCPU = ($Cluster | Get-VMHost | Select Name, @{Name=”LogicalCPU”;Expression={$_.ExtensionData.Hardware.CPUInfo.NumCPUThreads}} | Measure-Object -Sum LogicalCPU).Sum
$vCPU = ($Cluster | Get-VM | Measure-Object -Sum NumCPU).Sum
$V2PRatio = [math]::Round(($vCPU / $LCPU),2)
$ClusterStats = New-Object –TypeName PSObject $ClusterStats | Add-Member –MemberType NoteProperty –Name ClusterName –Value $Cluster.Name $ClusterStats | Add-Member –MemberType NoteProperty –Name LogicalCPU –Value $LCPU $ClusterStats | Add-Member –MemberType NoteProperty –Name vCPU –Value $vCPU $ClusterStats | Add-Member –MemberType NoteProperty –Name V2PRatio –Value $V2PRatio
$ClusterContentionRatio += $ClusterStats}
$ClusterContentionRatio

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s