Skip to content

Commit 69ee01a

Browse files
committed
CLOUDSTACK-3383: Fetch CPU utilization more reliable.
This should fix that we can't gather CPU statistics on hypervisors > Ubuntu 12.04
1 parent 50a3c0b commit 69ee01a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎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
@@ -3253,7 +3253,7 @@ private Answer execute(CheckHealthCommand cmd) {
32533253
private Answer execute(GetHostStatsCommand cmd) {
32543254
final Script cpuScript = new Script("/bin/bash", s_logger);
32553255
cpuScript.add("-c");
3256-
cpuScript.add("idle=$(top -b -n 1|grep Cpu\\(s\\):|cut -d% -f4|cut -d, -f2);echo $idle");
3256+
cpuScript.add("idle=$(top -b -n 1| awk -F, '/^[%]*[Cc]pu/{$0=$4; gsub(/[^0-9.,]+/,\"\"); print }'); echo $idle");
32573257

32583258
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
32593259
String result = cpuScript.execute(parser);

0 commit comments

Comments
 (0)