Cluster overview with capacity Print
Wednesday, 17 June 2009 16:56

@Depping asked me to send an overview of our current capacity, both hosts in clusters and storage. In half an hour I scripted this powershell script. This one checks all you clusters and hosts within, calculate the total available GB, GHz and in the end of the report, an overview of the datastores is presented (from John Tuffin's Blog)

Here is the script:

$VC = Connect-VIServer "<your vCenter Server here>"
$grandtotalGB = 0
$grandtotalGHz = 0
$Clusters = Get-Cluster -Location "<If needed, else delete it from -Location>" | sort name
foreach ($Cluster in $Clusters) {
$TotalGB = 0
$TotalGHz = 0
 
$ESXHosts = $Cluster | Get-VMHost | sort name
Write-Host $Cluster.name
foreach ($ESXHost in $ESXHosts) {
$ESXHostProp = $ESXHost | get-view
$ESXTotalGHz = [Math]::round($ESXHostProp.Hardware.CpuInfo.Hz/ 1GB) * $ESXHostProp.Hardware.CpuInfo.NumCpuCores
$ESXTotalGB = [Math]::round($ESXHostProp.Hardware.MemorySize/ 1GB)
$TotalGHz = $TotalGHz + $ESXTotalGhz
$TotalGB = $TotalGB + $ESXTotalGB
Write-Host " " $ESXHost.name ": Total GHz:" $ESXTotalGhz "- Total GB:" $ESXTotalGB
}
$TotalAvailableGB = $TotalGB-$ESXTotalGB
$TotalAvailableGHz = $TotalGHz-$ESXTotalGHz
Write-Host "Total GB =" $TotalGB
Write-Host "Total Available GB (n-1) =" $TotalAvailableGB
Write-Host "Total GHz =" $TotalGHz
Write-Host "Total Available GHz (n-1) =" $TotalAvailableGHz
Write-Host "-------------------------------------------------------------------"
$grandtotalGB = $grandtotalGB + $TotalAvailableGB
$grandtotalGHz = $grandtotalGHz + $TotalAvailableGHz
}
Write-Host "Total Available Memory : $grandtotalGB GB"
Write-Host "Total Available CPU : $grandtotalGHz GHz"
Get-Datastore | sort name | ft name,@{ Label = "FreespaceGB"; Expression = { [Math]::round($_.FreeSpaceMB * 1MB / 1GB) } }, @{ Label = "CapacityGB"; Expression = { [Math]::round($_.CapacityMB * 1MB / 1GB) } }

Comments (0)
Write comment
Your Contact Details:
Gravatar enabled
Comment:

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

 
Did you know: that ESX checks every 20ms to migrate a vCPU to another pCPU for the optimal workload balance. This is configurable (0ms - 5000ms) in Cpu.MigratePeriod in Advanced Settings of you ESX server.