Class: Pitchfork::MemInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/pitchfork/mem_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid) ⇒ MemInfo

Returns a new instance of MemInfo.



7
8
9
10
# File 'lib/pitchfork/mem_info.rb', line 7

def initialize(pid)
  @pid = pid
  update
end

Instance Attribute Details

#pssObject (readonly)

Returns the value of attribute pss.



5
6
7
# File 'lib/pitchfork/mem_info.rb', line 5

def pss
  @pss
end

#rssObject (readonly)

Returns the value of attribute rss.



5
6
7
# File 'lib/pitchfork/mem_info.rb', line 5

def rss
  @rss
end

#shared_memoryObject (readonly)

Returns the value of attribute shared_memory.



5
6
7
# File 'lib/pitchfork/mem_info.rb', line 5

def shared_memory
  @shared_memory
end

Instance Method Details

#cow_efficiency(parent_meminfo) ⇒ Object



12
13
14
# File 'lib/pitchfork/mem_info.rb', line 12

def cow_efficiency(parent_meminfo)
  shared_memory.to_f / parent_meminfo.rss * 100.0
end

#updateObject



16
17
18
19
20
21
22
# File 'lib/pitchfork/mem_info.rb', line 16

def update
  info = parse(File.read("/proc/#{@pid}/smaps_rollup"))
  @pss = info.fetch(:Pss)
  @rss = info.fetch(:Rss)
  @shared_memory = info.fetch(:Shared_Clean) + info.fetch(:Shared_Dirty)
  self
end