PerfQuerySpec qSpec = new PerfQuerySpec();
qSpec.setEntity(vmMor);
PerfMetricId[] availableMetricIds = (PerfMetricId[]) vmNetworkMetrics.toArray(new PerfMetricId[0]);
qSpec.setMetricId(availableMetricIds);
PerfQuerySpec[] qSpecs = new PerfQuerySpec[] {qSpec};
PerfEntityMetricBase[] values = service.queryPerf(perfMgr, qSpecs);
for(int i=0; i<values.length; ++i) {
PerfSampleInfo[] infos = ((PerfEntityMetric)values[i]).getSampleInfo();
sampleDuration = (infos[infos.length-1].getTimestamp().getTimeInMillis() - infos[0].getTimestamp().getTimeInMillis()) /1000;
PerfMetricSeries[] vals = ((PerfEntityMetric)values[i]).getValue();