Sha256: e76deeae949cdc802380f7e59e10521c63f142df73d498ad919f5bf068848c56

Contents?: true

Size: 575 Bytes

Versions: 13

Compression:

Stored size: 575 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)

    [
      { :service => plugin.service, :metric => fraction },
      { :service => plugin.service + " free", :metric => free.to_f },
      { :service => plugin.service + " total", :metric => total.to_f}
    ]
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
riemann-babbler-0.4.7 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.4.6 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.4.5 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.4.4 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.4.3 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.4.2 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.4.1 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.4.0 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.3.8 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.3.7 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.3.6 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.3.5 lib/riemann/babbler/plugins/memory.rb
riemann-babbler-0.3.4 lib/riemann/babbler/plugins/memory.rb