Skip to content

Commit ee8facd

Browse files
widoDaanHoogland
authored andcommitted
CLOUDSTACK-3383: Fetch CPU utilization more reliable.
This should fix that we can't gather CPU statistics on hypervisors > Ubuntu 12.04
1 parent 713a359 commit ee8facd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3255,7 +3255,7 @@ private Answer execute(CheckHealthCommand cmd) {
32553255
private Answer execute(GetHostStatsCommand cmd) {
32563256
final Script cpuScript = new Script("/bin/bash", s_logger);
32573257
cpuScript.add("-c");
3258-
cpuScript.add("idle=$(top -b -n 1|grep Cpu\\(s\\):|cut -d% -f4|cut -d, -f2);echo $idle");
3258+
cpuScript.add("idle=$(top -b -n 1| awk -F, '/^[%]*[Cc]pu/{$0=$4; gsub(/[^0-9.,]+/,""); print }'); echo $idle");
32593259

32603260
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
32613261
String result = cpuScript.execute(parser);

0 commit comments

Comments
 (0)