Sha256: 5c6b0a1af235e8fba4d0cdfcb209c0554f3acc05ed135277cfc2356150affaae

Contents?: true

Size: 1.52 KB

Versions: 59

Compression:

Stored size: 1.52 KB

Contents

#!/usr/bin/env ruby

require 'flapjack/filters/base'

module Flapjack
  module Filters

    # * If the service event's state is ok and there is unscheduled maintenance set, end the unscheduled
    #   maintenance
    # * If the service event’s state is ok and the previous state was ok, don’t alert
    # * If the service event’s state is ok and there's never been a notification, don't alert
    # * If the service event's state is ok and the previous notification was a recovery or ok, don't alert
    class Ok
      include Base

      def block?(event, entity_check, previous_state)
        unless event.ok?
          @logger.debug("Filter: Ok: pass")
          return false
        end

        entity_check.end_unscheduled_maintenance(Time.now.to_i)

        if previous_state == 'ok'
          @logger.debug("Filter: Ok: block - previous state was ok, so blocking")
          return true
        end

        last_notification = entity_check.last_notification
        @logger.debug("Filter: Ok: last notification: #{last_notification.inspect}")

        unless last_notification[:type]
          @logger.debug("Filter: Ok: block - last notification type is nil (never notified)")
          return true
        end

        if [:recovery, :ok].include?(last_notification[:type])
          @logger.debug("Filter: Ok: block - last notification was a recovery")
          return true
        end

        @logger.debug("Filter: Ok: previous_state: #{previous_state}")
        @logger.debug("Filter: Ok: pass")
        false
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
flapjack-0.8.7 lib/flapjack/filters/ok.rb
flapjack-0.8.6 lib/flapjack/filters/ok.rb
flapjack-0.8.5 lib/flapjack/filters/ok.rb
flapjack-0.8.4 lib/flapjack/filters/ok.rb
flapjack-0.8.3 lib/flapjack/filters/ok.rb
flapjack-0.8.2 lib/flapjack/filters/ok.rb
flapjack-0.8.1 lib/flapjack/filters/ok.rb
flapjack-0.8.0 lib/flapjack/filters/ok.rb
flapjack-0.7.35 lib/flapjack/filters/ok.rb
flapjack-0.7.34 lib/flapjack/filters/ok.rb
flapjack-0.7.33 lib/flapjack/filters/ok.rb
flapjack-0.7.32 lib/flapjack/filters/ok.rb
flapjack-0.7.31 lib/flapjack/filters/ok.rb
flapjack-0.7.30 lib/flapjack/filters/ok.rb
flapjack-0.7.29 lib/flapjack/filters/ok.rb
flapjack-0.7.28 lib/flapjack/filters/ok.rb
flapjack-0.7.27 lib/flapjack/filters/ok.rb
flapjack-0.7.26 lib/flapjack/filters/ok.rb
flapjack-0.7.25 lib/flapjack/filters/ok.rb