VMware {code} Community
Chandrashekhar
Contributor
Contributor
Jump to solution

How to get performance counter stats of virtual machine?

Hi again,

I have managed to connect to web service using VI SDK 2.5 and I can get what are the virtual machines installed on host system. I want to get performance counter values from virtual machines. How to get performance counter values from virtual machines?

try {

service = util.getConnection().getService();

sic = util.getConnection().getServiceContent();

perfMgr = sic.getPerfManager();

VMUtils utils = new VMUtils(util);

// Get list of virtual machines of an host

ArrayList vmList =utils.getVMs(null,null,null,null,null,arg,new String[1][2]);

if(vmList != null) {

System.out.println("Host has " + vmList.size() + " virtual machines");

System.out.println("vm name " + vmList.get(0).toString() + "vm 2 " + vmList.get(1).toString());

}

}

catch (Exception ex) {

ex.printStackTrace();

}

Any clues?

!http://communities.vmware.com/images/emoticons/sad.gif!

0 Kudos
1 Solution

Accepted Solutions
njain
Expert
Expert
Jump to solution

Hi,

In order to get the performance counter for a managed entity, you need to have following:

1. Get the managed object reference to the PerformanceManager object

2. Get the ProviderSummary object for this entity. It also helps in identifying whether the current or summary statistics are supported.

3. Get the available performance metrics for the entity. In a given time interval, the stats will be available for these metrics.

4. Query the performance stats for the desired entity for the metrics retrieved in above step

5. Drill down the returned data object to get the stats.

Attached is a Java sample, that takes the virtual machine name, executes the above steps and prints the available counters and their stats. You can take the help of this sample and can enhance it to get the stats for all virtual machines in your host.

Hope this information is helpful.

- Neha

View solution in original post

0 Kudos
2 Replies
njain
Expert
Expert
Jump to solution

Hi,

In order to get the performance counter for a managed entity, you need to have following:

1. Get the managed object reference to the PerformanceManager object

2. Get the ProviderSummary object for this entity. It also helps in identifying whether the current or summary statistics are supported.

3. Get the available performance metrics for the entity. In a given time interval, the stats will be available for these metrics.

4. Query the performance stats for the desired entity for the metrics retrieved in above step

5. Drill down the returned data object to get the stats.

Attached is a Java sample, that takes the virtual machine name, executes the above steps and prints the available counters and their stats. You can take the help of this sample and can enhance it to get the stats for all virtual machines in your host.

Hope this information is helpful.

- Neha

0 Kudos
Chandrashekhar
Contributor
Contributor
Jump to solution

Hi neha,

Thanks for reply.. Your example gave me one more idea for getting performance counter.

The way vmware provides counter information is somewhat complicated. Dont you think so? I have worked on performance counters of windows system, linux systems also. Out of all these , i found vmware more complex and difficult to understand.

0 Kudos