lib/riemann/babbler/plugins/cpu.rb in riemann-babbler-0.2.8 vs lib/riemann/babbler/plugins/cpu.rb in riemann-babbler-0.3.0

- old
+ new

@@ -1,13 +1,9 @@ class Riemann::Babbler::Cpu include Riemann::Babbler - def plugin - options.plugins.cpu - end - - def cpu + def collect cpu = File.read('/proc/stat') cpu[/cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/] u2, n2, s2, i2 = [$1, $2, $3, $4].map { |e| e.to_i } if @old_cpu @@ -16,20 +12,9 @@ total = used + i2-i1 fraction = used.to_f / total end @old_cpu = [u2, n2, s2, i2] - fraction + {"cpu" => fraction} end - def tick - current_state = cpu - report({ - :service => plugin.service, - :state => state(current_state), - :metric => current_state - }) - end - end - -Riemann::Babbler::Cpu.run