Sha256: 4c2148cfcc3d6c5ac57370c3278192085431a4f5d3bf4c1898a81ebc3584b8ad
Contents?: true
Size: 879 Bytes
Versions: 2
Compression:
Stored size: 879 Bytes
Contents
class Riemann::Babbler::Memory < Riemann::Babbler def collect m = File.read('/proc/meminfo').split(/\n/).inject({}) { |info, line| x = line.split(/:?\s+/) info[x[0]] = x[1].to_i info } free = m['MemFree'].to_i + m['Buffers'].to_i + m['Cached'].to_i total = m['MemTotal'].to_i fraction = 1 - (free.to_f / total) desc = "usage\n\n#{shell('ps -eo pmem,pid,cmd | sort -nrb -k1 | head -10').chomp}" [ { :service => plugin.service + " % free", :metric => fraction }, { :service => plugin.service + " % swap", :metric => (m['SwapTotal'] - m['SwapFree']).to_f/m['SwapTotal'] }, { :service => plugin.service + " total free", :metric => free.to_i, :state => 'ok', :description => desc }, { :service => plugin.service + " total total", :metric => total.to_i, :state => 'ok', :description => desc } ] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
riemann-babbler-0.5.2 | lib/riemann/babbler/plugins/memory.rb |
riemann-babbler-0.5.1 | lib/riemann/babbler/plugins/memory.rb |