class NewRelic::Agent::Samplers::MemorySampler::ShellPS

Public Class Methods

new(command) click to toggle source
# File lib/new_relic/agent/samplers/memory_sampler.rb, line 103
def initialize(command)
  super()
  @command = command
end

Public Instance Methods

get_memory() click to toggle source

Returns the amount of resident memory this process is using in MB

# File lib/new_relic/agent/samplers/memory_sampler.rb, line 110
def get_memory
  process = $$
  memory = %x`#{@command} #{process}`.split("\n")[1].to_f / 1024.0 rescue nil
  # if for some reason the ps command doesn't work on the resident os,
  # then don't execute it any more.
  raise "Faulty command: `#{@command} #{process}`" if memory.nil? || memory <= 0
  memory
end
to_s() click to toggle source
# File lib/new_relic/agent/samplers/memory_sampler.rb, line 118
def to_s
  "shell command sampler: #{@command}"
end