VMware Cloud Community
KiwiDave
Enthusiast
Enthusiast
Jump to solution

vcHostSystem Memory Usage

Hi,

I am trying to get the memory usage on a esx host but am not getting the expected output from the value:

selectedHost.summary.quickStats.overallMemoryUsage

where "selectedHost" is a VC:HostSystem.

The host is connected to vCenter but the same value is returned every time and seems to have no bearing on the actual memory usage on the host.

Am I missing something here?

Thanks,

Dave

0 Kudos
1 Solution

Accepted Solutions
tschoergez
Leadership
Leadership
Jump to solution

Just FYI: There is a bug in earlier (< 4.2 I think) versions of vCO/VC-Plugin about some performance counter. It seems to affect the host summary as well as Resource Pool summary.

But I got word that it got fixed in the current version, and I think that's also what you saw...

Cheers,

Joerg

View solution in original post

0 Kudos
4 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

Looks about right... one of my old workflows has the following content (host = VC:HostSystem and is the only input):

var byteToGiga=1024*1024*1024;
if (host != null){
     host.reload();
     System.log("--------------------------------------------");
     System.log("Host: "+host.name);
     System.log("Type: "+host.config.product.osType);
     System.log("Version: "+host.config.product.version);
     System.log("Build: "+host.config.product.build);
     System.log("Name: "+host.config.product.name);
     System.log("FullName: "+host.config.product.fullName);
     System.log("Product Line ID: "+host.config.product.productLineId);
     var hostVmCount = host.vm.length;
     System.log("VM Count: "+hostVmCount);
// Retrieve and format Host Memory Details
     var hostMemory = System.formatNumber(host.hardware.memorySize/byteToGiga,"0.");
     var hostUsedMemory = System.formatNumber(host.summary.quickStats.overallMemoryUsage/1000,"0.000"); // Returns in MB
     var hostFreeMemory = System.formatNumber(hostMemory - hostUsedMemory,"0.000");
     var percentMemory = System.formatNumber((hostUsedMemory/hostMemory)*100,"0");
     System.log("Total Host Memory GB: "+hostMemory);
     System.log("Host Used Memory GB: "+hostUsedMemory);
     System.log("Host Free Memory GB: "+hostFreeMemory);
// Retrieve Host CPU in hz & convert to Mhz
     var cpuCoreCount = host.hardware.cpuInfo.numCpuCores;
     var hostCPU = (host.hardware.cpuInfo.hz * cpuCoreCount)/1000000;
     var hostUsedCpu = host.summary.quickStats.overallCpuUsage; // Returns in Mhz
     var hostFreeCpu = hostCPU - hostUsedCpu;
// Now reformat all to Ghz by dividing by 1000
     hostCPU = System.formatNumber(hostCPU/1000,"0.000");
     hostUsedCpu = System.formatNumber(hostUsedCpu/1000,"0.000");
     hostFreeCpu = System.formatNumber(hostFreeCpu/1000,"0.000");
     var percentCPU = System.formatNumber((hostUsedCpu / hostCPU)*100,"0");
     System.log("Host CPU Ghz: "+hostCPU);
     System.log("Host Used CPU Ghz: "+hostUsedCpu);
     System.log("Host Free CPU Ghz: "+hostFreeCpu);
     var datastoreCount = host.datastore.length;
     System.log("Datastores: "+datastoreCount);
}

Here is sample output:

[2012-04-18 17:08:44.932] [I] --------------------------------------------

[2012-04-18 17:08:44.950] [I] Host: esx01.vmware.lan

[2012-04-18 17:08:45.458] [I] Type: vmnix-x86

[2012-04-18 17:08:45.918] [I] Version: 5.0.0

[2012-04-18 17:08:46.355] [I] Build: 469512

[2012-04-18 17:08:46.960] [I] Name: VMware ESXi

[2012-04-18 17:08:47.474] [I] FullName: VMware ESXi 5.0.0 build-469512

[2012-04-18 17:08:47.948] [I] Product Line ID: embeddedEsx

[2012-04-18 17:08:47.975] [I] VM Count: 62

[2012-04-18 17:08:48.017] [I] Total Host Memory GB: 48.

[2012-04-18 17:08:48.017] [I] Host Used Memory GB: 36.396

[2012-04-18 17:08:48.017] [I] Host Free Memory GB: 11.604

[2012-04-18 17:08:48.075] [I] Host CPU Ghz: 25.200

[2012-04-18 17:08:48.075] [I] Host Used CPU Ghz: 7.535

[2012-04-18 17:08:48.076] [I] Host Free CPU Ghz: 17.665

[2012-04-18 17:08:48.083] [I] Datastores: 3

After powering up a few more VMs and confirming vCenter shows a higher value for Memory usage, I ran the workflow again, but unfortunately got the same results. This is odd because the host.reload(); line is supposed to refresh the hostSystem object's properties!

My test was with vCO 4.2.0 build 5277 running on Windows... how about your environment... We should be sure to test under 4.2.1.

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
KiwiDave
Enthusiast
Enthusiast
Jump to solution

Hi Burke,

I am on 4.2.0 5277 Windows (need VIX), will try an upgrade to 4.2.1 and see how it goes.. will report back once done.

Cheers,

Dave

0 Kudos
KiwiDave
Enthusiast
Enthusiast
Jump to solution

Upgrade to 4.2.1 fixed it. Thanks for that Smiley Happy

0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

Just FYI: There is a bug in earlier (< 4.2 I think) versions of vCO/VC-Plugin about some performance counter. It seems to affect the host summary as well as Resource Pool summary.

But I got word that it got fixed in the current version, and I think that's also what you saw...

Cheers,

Joerg

0 Kudos