class Memstat::Proc::Status

Constants

FIELDS

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Memstat::Proc::Base::new
# File lib/memstat/proc/status.rb, line 7
def initialize(options = {})
  super
  @path ||= "/proc/#{@pid}/status"

  run
end

Public Instance Methods

run() click to toggle source
# File lib/memstat/proc/status.rb, line 14
def run
  @lines = File.readlines(@path).map(&:strip)
  @hash = {}

  @lines.each do |line|
    match = line.match(/(\w+):(.*)/)
    key = match[1]
    value = match[2]

    @hash[key] = value

    if match = key.match(/Vm(\w+)/)
      field = match[1].downcase
      if respond_to? "#{field}="
        send("#{field}=", Integer(value.strip.split.first) * 1024)
      end
    end
  end
end