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.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/06f79a88 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/06f79a88 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/06f79a88 Branch: refs/heads/rbac Commit: 06f79a881cce6e502a58aefa16a9068bced23b1f Parents: cb048f4 Author: Likitha Shetty <likitha.she...@citrix.com> Authored: Thu Jan 30 18:01:28 2014 +0530 Committer: Likitha Shetty <likitha.she...@citrix.com> Committed: Thu Jan 30 18:31:38 2014 +0530 ---------------------------------------------------------------------- .../cloud/hypervisor/vmware/resource/VmwareResource.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/06f79a88/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java ---------------------------------------------------------------------- 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 4073275..c609686 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<Long> 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 } } }