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
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
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 Detailsvar hostMemory = System.formatNumber(host.hardware.memorySize/byteToGiga,"0.");var hostUsedMemory = System.formatNumber(host.summary.quickStats.overallMemoryUsage/1000,"0.000"); // Returns in MBvar 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 Mhzvar cpuCoreCount = host.hardware.cpuInfo.numCpuCores;var hostCPU = (host.hardware.cpuInfo.hz * cpuCoreCount)/1000000;var hostUsedCpu = host.summary.quickStats.overallCpuUsage; // Returns in Mhzvar hostFreeCpu = hostCPU - hostUsedCpu;// Now reformat all to Ghz by dividing by 1000hostCPU = 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.
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
Upgrade to 4.2.1 fixed it. Thanks for that
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