VMware

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
4 Replies Last post: Nov 2, 2009 7:37 AM by AngelaS  

Looking for help on creating a C# class that can query for cpu utilization on a host posted: Oct 27, 2009 2:34 AM

Click to view shenji's profile Novice 5 posts since
Jun 9, 2006

I am having trouble writing a class to query for the cpu usage when you pass in a host and the required information. Does anyone have a sample code or a guide on how to write such a program?

Thanks

Click to view yvsvmware's profile Novice 14 posts since
Jun 22, 2009

You can retrieve the below properties from Host object to get the cpu utilization and overallmemoryusage

summary.quickStatsoverallCpuUsage

summary.quickStats.overallMemoryUsage

Thanks

Yvs

Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
Take a look here: http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.Summary.QuickStats.html

The vSphere API reference doc is your friend

If you're new to the VMware SDK/API's, please spend some time going over this doc: Getting Started with vSphere SDKs


=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
VMware Developer Comuunity
Twitter: @lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Click to view AngelaS's profile Enthusiast 43 posts since
Sep 28, 2009

Hi,

In order to retrieve the the HostSystem managed object, you can use findByDns or findByIp API to get the HostSystem. Then you can drill down to the overallCpuUsage property ( HostSystem->summary->quickstats->overallcpuUsage) to get the overall cpu usage of the host.

You might want to refer to the sample SearchIndex.cs, shipped with the vSphere SDK package, which demonstrates how to use FindByDns and FindByIp APIs.

Hope this helps.

Developer Social Media

Communities