lib/perus/pinger/metrics/cpu.rb in perus-0.1.2 vs lib/perus/pinger/metrics/cpu.rb in perus-0.1.3
- old
+ new
@@ -3,13 +3,13 @@
description 'Measures overall system CPU usage as a percentage on the
client.'
metric!
def run
- if `uname -s`.strip == 'Darwin'
- percent = 100 - `iostat -n 0`.split("\n")[2].split[2].to_i
+ if darwin?
+ percent = 100 - shell('iostat dxxvdfs -n 0').split("\n")[2].split[2].to_i
else
- percent = `grep 'cpu ' /proc/stat | awk '{print (1 - ($5 / ($2+$3+$4+$5+$6+$7+$8)))*100}'`
+ percent = shell("grep 'cpu ' /proc/stat | awk '{print (1 - ($5 / ($2+$3+$4+$5+$6+$7+$8)))*100}'")
end
{cpu_all: percent.to_f}
end
end