Class: TingYun::Agent::Collector::MemorySampler::Base
- Inherits:
-
Object
- Object
- TingYun::Agent::Collector::MemorySampler::Base
- Defined in:
- lib/ting_yun/agent/collector/middle_ware_collector/memory_sampler.rb
Direct Known Subclasses
Instance Method Summary collapse
- #can_run? ⇒ Boolean
- #get_memory ⇒ Object
- #get_sample ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
59 60 61 |
# File 'lib/ting_yun/agent/collector/middle_ware_collector/memory_sampler.rb', line 59 def initialize @broken = false end |
Instance Method Details
#can_run? ⇒ Boolean
63 64 65 66 67 |
# File 'lib/ting_yun/agent/collector/middle_ware_collector/memory_sampler.rb', line 63 def can_run? return false if @broken m = get_memory rescue nil m && m > 0 end |
#get_memory ⇒ Object
69 70 71 |
# File 'lib/ting_yun/agent/collector/middle_ware_collector/memory_sampler.rb', line 69 def get_memory raise 'Implement in the subclass' end |
#get_sample ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ting_yun/agent/collector/middle_ware_collector/memory_sampler.rb', line 73 def get_sample return nil if @broken begin m = get_memory if m.nil? ::TingYun::Agent.logger.warn "Unable to get the resident memory for process #{$$}. Disabling memory sampler." @broken = true end return m rescue => e ::TingYun::Agent.logger.warn "Unable to get the resident memory for process #{$$}. Disabling memory sampler.", e @broken = true return nil end end |