I have a performance collector written in Java that currently works with ESX 3.0 and 3.5 but fails on the queryPerf() SOAP call when pointed at 3i or 4i. My sample code is as follows
-
public PerfEntityMetricBase[] getPerfStats(ManagedObjectReference mor,Calendar sTime,Calendar eTime,PerfMetricId[] metricIds,Integer interval) throws Exception {
PerfQuerySpec qSpec = new PerfQuerySpec();
qSpec.setEntity(mor);
qSpec.setStartTime(sTime);
qSpec.setEndTime(eTime);
qSpec.setMetricId(metricIds);
qSpec.setIntervalId(interval);
PerfQuerySpec[] qSpecs = new PerfQuerySpec[] {qSpec};
PerfEntityMetricBase[] samples = this.sconn.getService().queryPerf(this.perfMoRef, qSpecs);
return samples
}
-
The error is
A specified parameter was not correct.
AxisFault
faultCode: ServerFaultCode
faultSubcode:
faultString: A specified parameter was not correct.
faultActor:
faultNode:
faultDetail:
InvalidArgumentFault:null
I've verified none of the qSpec parameters are null and the PerfMetricId array is built by querying the machine immediately before making this call so it is not as if I am using hard coded or stale parameters. My Axis is 1.4 (also tried 1.2).
Again, this works fine with ESX 3.0 or 3.5 but when I point to 3i or 4i it fails. Other parts of my code, such as querying the VM configuration data, works with no modifications. Am I missing something fundamentally obvious here by expecting 3i or 4i to be backwards compatible?
Thanks, Richard
SoapFault mentioned implies either of your paramters were incorrect. I am assuming that you called QueryAvailablePerfMetric API to retrieve metricIDs to be passed in your getPerfStats method and trying to fetch stats for Virtual Machine. Before passing metricIDs into your getPerfStats method, have you verified that PerfMetricIds were returned by your previous call? Did you check that your QueryAvailablePerfMetric API returned non-null array? Incase valid PerfMetricId array was returned then please verify if you are able to see any performance data for the Virtual Machine in the performance tab of the Virtual Machine in gthe VI Client and update us the results.
Hi, thanks for your reply. The following code is a little more robust and will recreate the problem
-
package queryperfbug;
import java.util.Calendar;
import com.vmware.vim2.*;
public class Main {
Calendar sDate = null;
Calendar eDate = null;
int collectInterval = 300;
public static void main(String[] args) {
if (args.length != 3) {
System.err.println("Usage: Main URL name password");
return;
}
Main m = new Main();
m.eDate = Calendar.getInstance(); // set end date to now()
m.sDate = Calendar.getInstance();
m.sDate.add(Calendar.HOUR, -1); // set begin date 1 hour ago
try {
m.getData(args[0], args[1], args[2]);
} catch(Exception e) {
System.err.println(e);
e.printStackTrace();
}
}
public void getData(String URL, String name, String pw) throws Exception {
// Step 1) Make connection with ESX Host
ServiceConnection sconn = new ServiceConnection("ServiceInstance");
sconn.connect(URL, name, pw);
ServiceUtil su = new ServiceUtil(sconn);
System.err.println("Connected... Step 1 Complete.");
// Step 2) Get Host and Perf References
ManagedObjectReference hostMoRef = su.getFirstDecendentMoRef(null,"HostSystem");
if (hostMoRef==null) System.err.println("hostMoRef is null");
ManagedObjectReference perfMoRef = sconn.getServiceContent().getPerfManager();
if (perfMoRef==null) System.err.println("perfMoRef is null");
System.err.println("Retrived MORs... Step 2 Complete");
// Step 3) Get Metrics available for time range
VimPortType svc = sconn.getService();
PerfMetricId[] pmids = svc.queryAvailablePerfMetric(perfMoRef, hostMoRef, sDate, eDate, collectInterval);
System.err.println(pmids.length + " Performance Metric IDs found... Step 3 Complete");
// Step 4) Get Performance stats for the just returned list of Metrics
PerfQuerySpec qSpec = new PerfQuerySpec();
qSpec.setEntity(hostMoRef);
qSpec.setStartTime(sDate);
qSpec.setEndTime(eDate);
qSpec.setMetricId(pmids);
qSpec.setIntervalId(collectInterval);
PerfQuerySpec[] qSpecs = new PerfQuerySpec[] {qSpec};
PerfEntityMetricBase[] samples = sconn.getService().queryPerf(perfMoRef, qSpecs);
System.err.println(samples.length + " Performance Metrics retrieved... Step 4 Complete");
}
}
A successfull run when pointed at an ESX 3.x server looks as follows:
Connected... Step 1 Complete.
Retrived MORs... Step 2 Complete
258 Performance Metric IDs found... Step 3 Complete
1 Performance Metrics retrieved... Step 4 Complete
When pointed at an ESXi server the output is:
Connected... Step 1 Complete.
Retrived MORs... Step 2 Complete
597 Performance Metric IDs found... Step 3 Complete
and then throws the above mentioned error.
I can in both cases view performance statistics via the client without error.
Let me know if you want me to post an entire working jar
Thanks,
Richard
I opened an incident on this and VMware was able to reproduce the problem. I'll update when I hear back.
Any solution to this problem?