Class: NewRelic::Agent::Samplers::MemorySampler::Base
- Inherits:
-
Object
- Object
- NewRelic::Agent::Samplers::MemorySampler::Base
show all
- Defined in:
- lib/new_relic/agent/samplers/memory_sampler.rb
Instance Method Summary
collapse
Instance Method Details
#can_run? ⇒ Boolean
61
62
63
64
65
|
# File 'lib/new_relic/agent/samplers/memory_sampler.rb', line 61
def can_run?
return false if @broken
m = get_memory rescue nil
m && m > 0
end
|
#get_sample ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/new_relic/agent/samplers/memory_sampler.rb', line 66
def get_sample
return nil if @broken
begin
m = get_memory
if m.nil?
NewRelic::Agent.instance.log.error "Unable to get the resident memory for process #{$$}. Disabling memory sampler."
@broken = true
end
return m
rescue => e
NewRelic::Agent.instance.log.error "Unable to get the resident memory for process #{$$}. (#{e})"
NewRelic::Agent.instance.log.debug e.backtrace.join("\n ")
NewRelic::Agent.instance.log.error "Disabling memory sampler."
@broken = true
return nil
end
end
|