VMware Cloud Community
SinghSingh
Hot Shot
Hot Shot

ESX Cluster Metric | Memory & CPU Unreserved

Hi,

I want to write a PS script which will allow me to look at an ESX Cluster and determine, regardless of the Guest VMs state (on,off), how much remaining compute capacity I have. This is important b\c I can then look at this data and determine if I need to buy new hardware.

Clusters expose metrics called 'memory unreserved' & CPU unreserved. - “CPU & Memory currently unreserved and available to be reserved by virtual machines and resource pools. Look at this number when trying to determine whether you can create a child resource pool of a certain size, or whether you can power on a virtual machine with a certain reservation.” I found this info in the VMware DRS whitepaper.

Unit

KB

Description

Amount of unreserved memory

Statistic type

Absolute

Rollup type

Average,minimum, maximum

Entity

Host,compute resource

I'd like to know if anyone has any input on this approach. Am I overlooking anything? Has anyone seen a similar script out there already? Lastly, any direction of best to appraoch this would be greatly appreciated.

Thanks,

0 Kudos
2 Replies
h89
Contributor
Contributor

Hi Rajesh,

I am trying the same using the script. Did you manage to get the script working??? Can you please send me at .

This should save heaps of my effort. Thanks mate.

0 Kudos
LucD
Leadership
Leadership

I must have missed your post.

Anyway, I don't think that these metrics are gathered for clusters.

The latest SDK Programming Guide (Revision: 20090113) states in Appendix A Performance Counter Reference that:

  • mem.unreserved for all rollup types is only collected for hosts and compute resources.

  • cpu.reservedCapacity in MHz (indirectly gives us what is unreserved) is only collected for hosts

Note also that a ComputeResource is not the same as a ClusterComputeResource.

The information you want is available in the ResourcePoolResourceUsage object.

Note the important remark on that SDK page about the difference between expandable and non-expandable resources !

The following script lists the unreserved Cpu and Memory resources.

$cluster = Get-Cluster <cluster-name> | Get-View

$respool = Get-View $cluster.ResourcePool
$unreservedCpu = $respool.Summary.Runtime.Cpu.UnreservedForPool
$unreservedMem = $respool.Summary.Runtime.Memory.UnreservedForPool/1Mb
Write-Host "Unreserved CPU (MHz)" $unreservedCpu
Write-Host "Unreserved Mem (Mb) " $unreservedMem

If you run the script at regular intervals you should get a good view how the unreserved resources grow/shrink.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos