Last active
August 29, 2015 14:21
-
-
Save Sam-Martin/1dd99c4c6597a447461b to your computer and use it in GitHub Desktop.
Get VMWare Cluster Contention
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach($cluster in Get-Cluster){ | |
# Get host memory free | |
$vmHostObj = $cluster | Get-VMHost | |
$totalVMHostMemory = [int]$($vmHostObj | measure-object -property MemoryTotalGB -sum).sum; | |
$totalVMHostMemoryFree = $($vmHostObj | %{$_.MemoryTotalGB - $_.MemoryUsageGB} | measure-object -sum).sum; | |
$highestHostMemoryTotal = $($vmHostObj | sort-object -property MemoryTotalGB | select -last 1).MemoryTotalGB; | |
$totalVMHostCPU = [int]$($vmHostObj | measure-object -property CPUTotalMhz -sum).sum; | |
$totalVMHostCPUFree = $($vmHostObj | %{$_.CPUTotalMhz - $_.CPUUsageMhz} | measure-object -sum).sum; | |
$highestHostCPUTotal = $($vmHostObj | sort-object -property CPUTotalMhz | select -last 1).CPUTotalMhz; | |
New-Object PSObject -Property @{ | |
Cluster= $cluster.Name | |
TotalVMHostCPUMhz = $totalVMHostCPU | |
TotalVMhostCPUFree = $totalVMHostCPUFree | |
TotalVMHostMemory = $totalVMHostMemory | |
TotalVMHostMemoryFree = $totalVMHostMemoryFree | |
"Number of hosts that can be lost (memory)" = $([Math]::Round($totalVMHostMemoryFree/$highestHostMemoryTotal,2)) | |
"Number of hosts that can be lost (CPU)" = $([Math]::Round($totalVMHostCPUFree/$highestHostCPUTotal,2)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment