Sha256: eb3d0709e05dea034177e62a227e9eeab29f2f70626007af7753a6e267b4e909

Contents?: true

Size: 530 Bytes

Versions: 4

Compression:

Stored size: 530 Bytes

Contents

class Eye::Trigger::Flapping < Eye::Trigger

  # triggers :flapping, :times => 10, :within => 1.minute

  param :times, [Fixnum], true
  param :within, [Float, Fixnum], true

  def good?
    return true unless within

    states = @states_history.states_for_period( within )

    starting_count = states.count{|st| st == :starting}
    down_count = states.count{|st| st == :down}
    times_count = times || 5

    if (starting_count >= times_count) && (down_count >= times_count)
      false
    else
      true
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eye-0.2.2 lib/eye/trigger/flapping.rb
eye-0.2.1 lib/eye/trigger/flapping.rb
eye-0.2 lib/eye/trigger/flapping.rb
eye-0.1.11 lib/eye/trigger/flapping.rb