Sha256: 73406465e2f6e024053b9400bc778b30a355db8aa00894b0c0c551964fc65c49
Contents?: true
Size: 456 Bytes
Versions: 1
Compression:
Stored size: 456 Bytes
Contents
class Riemann::Babbler::Cpu < 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] { :service => plugin.service, :metric => fraction } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
riemann-babbler-0.4.6 | lib/riemann/babbler/plugins/cpu.rb |