From 06f79a881cce6e502a58aefa16a9068bced23b1f Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Thu, 30 Jan 2014 18:01:28 +0530 Subject: [PATCH] CLOUDSTACK-5994. Hitting IndexOutOfBoundsException in GetVmStatsCommand after upgrade. To obtain network read/write statistics, multiply sample duration with the average of the particular performance metric obtained over the sample period. --- .../cloud/hypervisor/vmware/resource/VmwareResource.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 407327592bc..c609686efa1 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -5290,11 +5290,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa if (vals.get(vi) instanceof PerfMetricIntSeries) { PerfMetricIntSeries val = (PerfMetricIntSeries)vals.get(vi); List perfValues = val.getValue(); + Long sumRate = 0L; + for (int j = 0; j < infos.size(); j++) { // Size of the array matches the size as the PerfSampleInfo + sumRate += perfValues.get(j); + } + Long averageRate = sumRate / infos.size(); if (vals.get(vi).getId().getCounterId() == rxPerfCounterInfo.getKey()) { - networkReadKBs = sampleDuration * perfValues.get(3); //get the average RX rate multiplied by sampled duration + networkReadKBs = sampleDuration * averageRate; //get the average RX rate multiplied by sampled duration } if (vals.get(vi).getId().getCounterId() == txPerfCounterInfo.getKey()) { - networkWriteKBs = sampleDuration * perfValues.get(3);//get the average TX rate multiplied by sampled duration + networkWriteKBs = sampleDuration * averageRate;//get the average TX rate multiplied by sampled duration } } }