lib/riemann/babbler/plugins/cpu.rb in riemann-babbler-1.1.0pre2 vs lib/riemann/babbler/plugins/cpu.rb in riemann-babbler-1.1.6

- old
+ new

@@ -1,15 +1,19 @@ #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 = 'Cpu usage' + description = desc 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?