Is it possible to capture the number of cores on a physical host, then calculate the vCPU to core ratio using powerCLI?
Try something like this
Get-VMHost | Select Name,
@{N="pCores";E={$script:pCPU = $_.ExtensionData.Hardware.CpuINfo.NumCpuCores; $pCPU}},
@{N="vCores";E={
$script:vCPU = Get-VM -Location $_ | %{
$_.ExtensionData.Config.Hardware.NumCPU * $_.ExtensionData.Config.Hardware.NumCoresPerSocket
} | Measure-Object -Sum | Select -ExpandProperty Sum
$vCPU
}},
@{N="Ratio vCore/pCore";E={[math]::Round(($script:vCPU/$script:pCPU),2)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Get-VMHost | Select Name,
@{N="pCores";E={$script:pCPU = $_.ExtensionData.Hardware.CpuINfo.NumCpuCores; $pCPU}},
@{N="vCores";E={
$script:vCPU = Get-VM -Location $_ | %{
$_.ExtensionData.Config.Hardware.NumCPU * $_.ExtensionData.Config.Hardware.NumCoresPerSocket
} | Measure-Object -Sum | Select -ExpandProperty Sum
$vCPU
}},
@{N="Ratio vCore/pCore";E={[math]::Round(($script:vCPU/$script:pCPU),2)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Connect-VIServer $vcserver
$stats = @()
$Datacenter = Get-Datacenter
Foreach ($dc in $datacenter)
{
$cluster = get-cluster -location $dc
foreach ($cl in $cluster)
{
$row = New-Object System.Object
$row | Add-Member -Type NoteProperty -Name "Name" -Value "$dc\$Cl"
$ClusterVMs = $Cl | Get-VM
$ClusterCPUCores = $Cl.ExtensionData.Summary.NumCpuCores
$row | Add-Member -Type NoteProperty -Name "pCPU" -Value "$ClusterCPUCores"
$ClusterAllocatedvCPUs = ($ClusterVMs | Measure-Object -Property NumCPu -Sum).Sum
$row | Add-Member -Type NoteProperty -Name "vCPU" -Value "$ClusterAllocatedvCPUs"
$ClusterRatio = 0
$ClusterRatio = [math]::round($ClusterAllocatedvCPUs / $ClusterCPUCores,2)
$row | Add-Member -Type NoteProperty -Name "Ratio" -Value " 1 : $ClusterRatio "
$stats += $row
}
}
$Stats = $Stats | Sort Ratio -Descending
OK great thanks