Sha256: a90a669657b0a42b3b4b0392b8e88cbd8eaa44cb58936b1adaaf896c9d7c7c08
Contents?: true
Size: 772 Bytes
Versions: 1
Compression:
Stored size: 772 Bytes
Contents
class Riemann::Babbler::Cpu include Riemann::Babbler def plugin options.plugins.cpu end def cpu 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] log.error fraction fraction end def tick current_state = cpu # при первом проходе у нас будет nil next unless current_state report({ :service => plugin.service, :state => state(current_state), :metric => current_state }) end end Riemann::Babbler::Cpu.run
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
riemann-babbler-0.0.3 | lib/riemann/babbler/plugins/cpu.rb |