VMware Cloud Community
bdamian
Expert
Expert

Host Total Capacity from Resource Allocation tab

Hi all,

Starting with a VcHostSystem object, do you know how I can reach the values of "CPU total capacity" and "Memory total capacity" shown in vCenter -> Resource Allocation Tab?

I need to create resources pool and I'm reading "host.hardware.memorySize" but this is the total memory of the computer, not the size utilizable for VMs and throws the error "The available Memory resources in the parent resource pool are insufficient for the operation".

I've attached a screenshot of the values I need to read from the object.

Thanks a lot.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
0 Kudos
10 Replies
Burke-
VMware Employee
VMware Employee

Assuming you have your ESXi Host object named "esxHost" in the script, this might be what you are looking for:

System.log("CPU Total Capacity: "+esxHost.parent.summary.effectiveCpu);

System.log("Memory Total Capacity: "+esxHost.parent.summary.effectiveMemory);

Those values come from the Compute Resource that the host is a child of. In the case of a cluster, it is a cluster compute resource and a standalone host it is simply a compute resource - I think Smiley Wink

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
bdamian
Expert
Expert

Hi Burke,

Thanks for your help. This is great, but I steel need this values for a single Host. If you connect vCenter client directly to a host, you can see those numbers. So, how can I reach this values from a host?

I'm attaching a screenshot.

Thanks a lot,

D.host.PNG

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
0 Kudos
Burke-
VMware Employee
VMware Employee

It seems you missed part of my explanation - that code should present you with the information you are seeking .. the screenshot you are showing is a single host NOT in a cluster - so, esxHost.parent returns the compute resource (root resources pool for the host) - this compute resource is where the "Resource Allocation" tab of the vSphere client gets its numbers. You will note that when a host IS in a cluster, it does NOT have a "Resource Allocation" tab - the cluster it is a member of has that tab.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
bdamian
Expert
Expert

Hi Burk,

I understand your explanation. But, the screenshot I've sent you before is a host in a cluster. I've just connect directly to it.

Let me ask again. How do I know the impact on effective resources in a Cluster if I remove a host?

I've made the following test: I've put a host outside all clusters so, I've seen theese values (ex: 7663MHz and 3637MB). When I add this host to a cluster, theese are the values added to the "effective cpu and memory" of the cluster. If I remove the host of the cluster, those are the values that the cluster losts.

So, here is my cuestion again. How can I "see" a HostSystem from a cluster as a ComputeResource (vSphere Client can do this)? I need to know those values even if the host is part of a Cluster.

Thanks.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
0 Kudos
bdamian
Expert
Expert

Hi Burk, me again.

In this link are the properties of the "VcClusterHostPowerAction": http://www.vmware.com/support/orchestrator/doc/vco_vsphere51_api/html/VcClusterHostPowerAction.html

There are 2 properties:

cpuCapacityMHz: In case of power off, this is the projected decrease in the cluster's CPU capacity.

memCapacityMB: In case of power off, this is the projected decrease in the cluster's memory capacity.

This is what I need. But I cannot find the path from "VcHostSystem" to "VcClusterHostPowerAction".

Do you?

Thanks.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
0 Kudos
Burke-
VMware Employee
VMware Employee

Okay, now you've pointed to different information... This was a bit challenging to figure out too since no project I've ever been involved in got anywhere near this particular object... The "VcClusterHostPowerAction" is a type of VcClusterAction. And that is a property of a cluster recommendation ... so you don't get this information by host - you get it by cluster and it's a bit complicated because it is based on a DRS recommendation. I ( and those I asked for assistance from ) don't believe this is what you actually need based on this thread. Instead, you should just be concerned with your host's overhead + memory used. This will get you an approximate value for the "capacity" that the host is adding to a cluster Smiley Happy This took a bit of digging to figure out.

So for an individual host, it should be approximately:

var memUsage = esxHost.summary.quickStats.overallMemoryUsage;

System.log("Memory Usage: "+memUsage);

var configs = esxHost.systemResources.child;

for each (var child in configs){

if(child.key == "host/system"){

var hostReservation = child.config.memoryAllocation.reservation;

}

}

var hostOverhead = memUsage + hostReservation;

var totalCapacity = esxHost.hardware.memorySize / (1024*1024);

var availableCapacity = totalCapacity - hostOverhead;

System.log("Host Overhead: "+hostOverhead);

System.log("Total Capacity: "+totalCapacity);

System.log("Available Capacity: "+availableCapacity);

In my test cluster, I have 3 hosts - each with 8GB memory the above code properly reflects a single host's memory for the cluster "Capacity" as you are requesting. Obtaining cpu info will be nearly identical as each object I obtained Memory info from also has CPU details.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
bdamian
Expert
Expert

Hi Burk,

I ran this script in my lab and get theese results:

[2013-12-09 16:57:40.694] [I] Memory Usage: 1023

[2013-12-09 16:57:53.236] [I] Host Overhead: 1023

[2013-12-09 16:57:53.236] [I] Total Capacity: 6143.48828125

[2013-12-09 16:57:53.236] [I] Available Capacity: 5120.48828125

The "Total Capacity" is exactly as the value I see in the console, but, the real value of Available Capacity for this host (as you can see in the previous screenshot) is 3634MB so is not really close enought. I will give a try on VcClusterAction.

Anyway, I'm steel thinking about how to see a HostSystem as a ComputeResource because vSphere Client clearly can do this.

By the way, the business rule I'm trying to accomplish is to create a resource pool with capacity of all available resources minus the biggest host. So, I have the total capacity of the cluster but I need to know the values of all hosts to determine how much resources to save.

Thanks.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
0 Kudos
Burke-
VMware Employee
VMware Employee

Please try the workflow I just posted here: Get Host Effective Capacity

I took the code from this thread and did a bit of cleanup, added CPU info to it and changed the .log to .debug and added an extra logging info. Your output seems to indicate that you don't have any host memory reservation which just doesn't sound right... The host you are running this against - is it in a cluster or out of a cluster?

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
admin
Immortal
Immortal

he metric used to calculate the Total Capacity value for Memory on the Resource Allocation page for the cluster is not the same metric used for the memory available for virtual machines on the ESX/ESXi configuration tab.  Each host does have its own Resource Allocation tab, but it is not shown in vCenter Server.

To see the ESX/ESXi host Resource Allocation tab, use the vSphere Client to connect directly to each host. The Total Capacity for Memory values from each host in the cluster should add up to the same value shown at the cluster level in vCenter Server. 

0 Kudos
bdamian
Expert
Expert

That's right, AlbertoLo,

If you move the esxi outside of the cluster, you also see that tab. The problem is: if the esxi is outside any cluster, vCenter shows it as a "ComputeResource", but when the esxi is inside a cluster, shows it as a HostSystem.

Nonetheless, vCenter can access that values because add it or remove it at once when you add the esxi to the cluster or when you remove it.

The api's failure is not allow us to see a HostSystem as a ComputeResource when the esxi is part of a cluster.

D.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
0 Kudos