Sha256: 4aed057dd0334c9115fe4b9ed35a43d8c58c84ebed34c5816210227e0c471d4c
Contents?: true
Size: 432 Bytes
Versions: 2
Compression:
Stored size: 432 Bytes
Contents
class Riemann::Babbler::Cpu include Riemann::Babbler 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 u1, n1, s1, i1 = @old_cpu used = (u2+n2+s2) - (u1+n1+s1) total = used + i2-i1 fraction = used.to_f / total end @old_cpu = [u2, n2, s2, i2] {"cpu" => fraction} end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
riemann-babbler-0.3.1 | lib/riemann/babbler/plugins/cpu.rb |
riemann-babbler-0.3.0 | lib/riemann/babbler/plugins/cpu.rb |