Class: Memstat::Proc::Status
Constant Summary collapse
- FIELDS =
%w[peak size lck pin hwm rss data stk exe lib pte swap]
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Status
constructor
A new instance of Status.
- #run ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ Status
Returns a new instance of Status.
7 8 9 10 11 12 |
# File 'lib/memstat/proc/status.rb', line 7 def initialize( = {}) super @path ||= "/proc/#{@pid}/status" run end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |