Quick and Dirty VMware vApp Resource Share Auditing
Posted on September 15, 2016
Nope, this isn’t yet another blog post explaining resource pools.
By now everyone should know how they work, and if not, you’ve been linked to 99% of what there is to know. We should also all know that vApps act exactly like resource pools, so when they’re created, or have VMs modified, added, or removed, the resource shares need to be updated, just like with a resource pool.
This post is a quick and dirty powershell ‘copy and paste ’ script which looks at existing resource pools and works out what the CPU and Memory shares should be set to assuming you want a Normal allocation and that you’re using the VMware default share values. It prints out what the values of each allocation should be set to, in green if it’s set correctly, and in red if either the CPU or RAM differs.
function Get-vAppResources {
foreach ($vApp in Get-Vapp) {
$CPUShares = 0
$MemoryShares = 0
foreach ($VM in $vApp | Get-VM) {
$CPUShares += $VM.NumCpu
$MemoryShares += $VM.MemoryMB
}
$CPUShares = $CPUShares * 1000
$MemoryShares = $MemoryShares * 10
if ($CPUShares -eq $vApp.NumCPUShares -and $MemoryShares -eq $vApp.NumMemShares) { $fg = "Green" }
else { $fg = "Red" }
# Outputs what the values should be in a balanced cluster
Write-Host $vApp.Name CPU: $CPUShares, Memory: $MemoryShares -backgroundcolor "Black" -foregroundcolor $fg
}
}
Lots of room for improvement, but this will give you a quick overview.