Repository: cloudstack Updated Branches: refs/heads/4.5 9f8d0051e -> 93b2b3a4a
CLOUDSTACK-3383: Fetch CPU utilization more reliable. This should fix that we can't gather CPU statistics on hypervisors > Ubuntu 12.04 (cherry picked from commit 69ee01af9df8d72ccd8901d146726e74edda95d7) Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/93b2b3a4 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/93b2b3a4 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/93b2b3a4 Branch: refs/heads/4.5 Commit: 93b2b3a4ae2ff2f4ecd3592ac6b7ff58714baeba Parents: 9f8d005 Author: Wido den Hollander <w...@widodh.nl> Authored: Tue Nov 11 16:49:38 2014 +0100 Committer: Rohit Yadav <rohit.ya...@shapeblue.com> Committed: Fri Nov 21 20:20:58 2014 +0530 ---------------------------------------------------------------------- .../cloud/hypervisor/kvm/resource/LibvirtComputingResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b2b3a4/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 55b49c2..b95d53b 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -3251,7 +3251,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv private Answer execute(GetHostStatsCommand cmd) { final Script cpuScript = new Script("/bin/bash", s_logger); cpuScript.add("-c"); - cpuScript.add("idle=$(top -b -n 1|grep Cpu\\(s\\):|cut -d% -f4|cut -d, -f2);echo $idle"); + cpuScript.add("idle=$(top -b -n 1| awk -F, '/^[%]*[Cc]pu/{$0=$4; gsub(/[^0-9.,]+/,\"\"); print }'); echo $idle"); final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); String result = cpuScript.execute(parser);