vijaybhosale
Contributor
Contributor

What should be PerfQuerySpec StartTime and EndTime Value?

Hi,

I am writing the code to get all VM and ESX server Performance data from VC.

I am bit confuse about what should be the startTime and endTime PerfQuerySpec filter property values?

Do I need to use VC server current Time or I will have to query CurrentTime from all the host server and set that time for querying perf. data?

I have written code to get VC server Time using CurrentTime() API but doesn't work. This API returened Client machine currentTime.

start = this._service.currentTime( this._svcRef );

System.out.println("Service CurrentTime "+start.getTime()); --> Here it print client machine currentTime.

The help will be greatly appreciated.

Thanks,

Vijay

0 Kudos
4 Replies
Steve_Jin
Expert
Expert

The PerfQuerySpec is passed to the VC server, therefore it should be time of the VC server. The way you retrieve the VC server time looks fine to me.

The filter's startTime and endTime is to specify a period for which you want the historical statistics. If the start is the current time of the vc server, meaning you will get nothing because there is no history data from the server side "now".

You may want to specify the startTime to a time a while back, and endTime to "now".

Steve JIN, VMware Engineering

Creator of VI Java API:

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
vijaybhosale
Contributor
Contributor

Thanks Steve,

The below code snippet fetching the client machine time instead of VC

server time.

start = this._service.currentTime( this._svcRef );

System.out.println("Service CurrentTime "+start.getTime());

Can you please tell me the exact steps to get VC server time using VI

SDK?

Thanks,

Vijay

0 Kudos
vijaybhosale
Contributor
Contributor

The below code snippet which giving me the client machine time instead of VC server time.

start = this._service.currentTime( this._svcRef );

System.out.println("Service CurrentTime "+start.getTime());

Can some one tell me the exact steps to get VC server time using VI SDK?

0 Kudos
Steve_Jin
Expert
Expert

I assume ._svcRef is the ManagedObjectReference to the ServiceInstance. You code seems fine.

If your code is running on the same machine as VC server, you will have the same current time.

Steve JIN, VMware Engineering

Creator of VI Java API:

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos