Class: NewRelic::Agent::Samplers::MemorySampler::ProcStatus
- Defined in:
- lib/new_relic/agent/samplers/memory_sampler.rb
Overview
ProcStatus
A class that samples memory by reading the file /proc/$$/status, which is specific to linux
Instance Method Summary collapse
-
#get_memory ⇒ Object
Returns the amount of resident memory this process is using in MB.
- #proc_status_file ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
Instance Method Details
#get_memory ⇒ Object
Returns the amount of resident memory this process is using in MB
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/new_relic/agent/samplers/memory_sampler.rb', line 122 def get_memory File.open(proc_status_file, "r") do |f| while !f.eof? if f.readline =~ /RSS:\s*(\d+) kB/i return $1.to_f / 1024.0 end end end raise "Unable to find RSS in #{proc_status_file}" end |
#proc_status_file ⇒ Object
132 133 134 |
# File 'lib/new_relic/agent/samplers/memory_sampler.rb', line 132 def proc_status_file "/proc/#{$$}/status" end |
#to_s ⇒ Object
135 136 137 |
# File 'lib/new_relic/agent/samplers/memory_sampler.rb', line 135 def to_s "proc status file sampler: #{proc_status_file}" end |