Class: Reacter::FilterAgent

Inherits:
Agent
  • Object
show all
Defined in:
lib/reacter/agents/filter.rb

Instance Attribute Summary

Attributes inherited from Agent

#config, #type

Instance Method Summary collapse

Methods inherited from Agent

create

Constructor Details

#initializeFilterAgent

Returns a new instance of FilterAgent.



8
9
10
11
# File 'lib/reacter/agents/filter.rb', line 8

def initialize()
  super
  @@_rxcache = {}
end

Instance Method Details

#received(message) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/reacter/agents/filter.rb', line 13

def received(message)
  if @config['sources'].is_a?(Hash)
  # config not found, drop
    return false if @config['sources'].empty?

    @config['sources'].each do |sources, metrics|
      sources = [*sources]
      metrics = [*metrics]


      sources.each do |source|
        if source === 'default' or _property_match?(message.source, source)
        # no metrics means all metrics!
          return message if metrics.nil? or metrics.first === true or metrics.empty?

          metrics.each do |metric|
            if _property_match?(message.metric, metric)
              return message
            end
          end
        end
      end
    end
  end

  return false
end