Performance Counter Example (QueryPerf)

The following code fragments are part of an example that uses the PerformanceManager.QueryPerf method to obtain performance statistics for a virtual machine.

The example code in this section does not include server connection code and it does not show the code for obtaining the managed object reference for the virtual machine. See Client Applications for the Web Services API for an example of server connection code.

This example retrieves the following statistics:

  • disk.provisioned.LATEST – virtual machine storage capacity.
  • mem.granted.AVERAGE – amount of physical memory mapped for the virtual machine.
  • power.power.AVERAGE – current power usage.

The example creates a query specification (PerfQuerySpec) to identify the data to be retrieved, calls the QueryPerf method, and prints out the retrieved performance data and corresponding performance counter metadata. The following sections describe the basic steps involved in retrieving performance statistics.