Class: Eye::Trigger::Flapping

Inherits:
Eye::Trigger show all
Defined in:
lib/eye/trigger/flapping.rb

Constant Summary

Constants inherited from Eye::Trigger

TYPES

Instance Attribute Summary

Attributes inherited from Eye::Trigger

#message, #options

Attributes included from Dsl::Validation

#defaults, #should_bes, #validates, #variants

Attributes included from Logger::Helpers

#logger

Instance Method Summary collapse

Methods inherited from Eye::Trigger

#check, create, get_class, validate!

Methods included from Dsl::Validation

#inherited, #param, #validate

Constructor Details

#initialize(*args) ⇒ Flapping

Returns a new instance of Flapping.



11
12
13
14
# File 'lib/eye/trigger/flapping.rb', line 11

def initialize(*args)
  super
  @last_at = nil
end

Instance Method Details

#good?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/eye/trigger/flapping.rb', line 16

def good?
  states = @states_history.states_for_period( within, @last_at )
  down_count = states.count{|st| st == :down }

  if down_count >= times
    @last_at = @states_history.last_state_changed_at
    false
  else
    true
  end
end