PowerCLI

 View Only
  • 1.  Total CPU per cluster

    Posted May 18, 2009 09:45 PM

    How do I pull out the total cpu for each cluster via powershell? This would be the information showed on the summary page.

    I basically had 10 host and i want the total ghz count for the cluster so i can do some calculations and reporting.

    Truth is a three edged sword



  • 2.  RE: Total CPU per cluster

    Posted May 19, 2009 05:10 AM

    That info is available in the totalCpu property in the ComputeResourceSummary object.

    For one reason or another the VIC seems to always round this number down, hence the floor function in the script

    $cluster = Get-Cluster <cluster-name> | Get-View
    $totalCPUraw = $cluster.Summary.TotalCpu / 1000
    $totalCPU = [math]::Floor($totalCPUraw)
    
    write-host "Total CPU Resources:`t" ("{0:N0}" -f $totalCPU) "GHz"
    

    Or as a one-liner

    write-host "Total CPU Resources:`t" ("{0:N0}" -f ([math]::Floor((Get-Cluster <cluster-name> | Get-View).Summary.TotalCpu / 1000))) "GHz"