PowerCLI

 View Only
  • 1.  Determing vCPU to Core ratios

    Posted Oct 09, 2013 02:14 PM

    Is it possible to capture the number of cores on a physical host, then calculate the vCPU to core ratio using powerCLI?



  • 2.  RE: Determing vCPU to Core ratios
    Best Answer

    Posted Oct 09, 2013 05:50 PM

    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)}}


  • 3.  RE: Determing vCPU to Core ratios

    Posted Jan 17, 2014 07:37 PM

    OK great thanks



  • 4.  RE: Determing vCPU to Core ratios

    Posted Oct 14, 2013 07:34 PM

    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