lib/riemann/babbler/plugins/cpu.rb in riemann-babbler-1.0.8.8 vs lib/riemann/babbler/plugins/cpu.rb in riemann-babbler-1.1.0pre2
- old
+ new
@@ -1,19 +1,15 @@
#encoding: utf-8
class Riemann::Babbler::Cpu < Riemann::Babbler
- def desc
- "#{shell('ps -eo pcpu,pid,cmd --sort -pcpu | head -3').chomp}"
- end
-
def init
@old_cpu = Hash.new
end
def collect
array = Array.new
- description = desc
+ description = 'Cpu usage'
File.read('/proc/stat').split("\n").each do |cpu_line|
# проверяем есть строчка /cpu\d+/ или /cpu / и сграбливаем это в переменную
cpu_number = cpu_line.scan(/cpu(\d+|\s)\s+/)
next if cpu_number.empty?