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-1.6.0 lib/flapjack/filters/ok.rb
flapjack-1.6.0rc4 lib/flapjack/filters/ok.rb
flapjack-1.6.0rc3 lib/flapjack/filters/ok.rb
flapjack-1.6.0rc2 lib/flapjack/filters/ok.rb
flapjack-1.6.0rc1 lib/flapjack/filters/ok.rb
flapjack-1.5.0 lib/flapjack/filters/ok.rb
flapjack-1.5.0rc1 lib/flapjack/filters/ok.rb
flapjack-1.4.0 lib/flapjack/filters/ok.rb
flapjack-1.4.0rc1 lib/flapjack/filters/ok.rb
flapjack-1.3.0 lib/flapjack/filters/ok.rb
flapjack-1.3.0rc3 lib/flapjack/filters/ok.rb
flapjack-1.3.0rc2 lib/flapjack/filters/ok.rb
flapjack-1.3.0rc1 lib/flapjack/filters/ok.rb
flapjack-1.2.2 lib/flapjack/filters/ok.rb
flapjack-1.2.1 lib/flapjack/filters/ok.rb
flapjack-1.2.1rc3 lib/flapjack/filters/ok.rb
flapjack-1.2.1rc2 lib/flapjack/filters/ok.rb
flapjack-1.2.1rc1 lib/flapjack/filters/ok.rb
flapjack-1.2.0 lib/flapjack/filters/ok.rb
flapjack-0.9.6 lib/flapjack/filters/ok.rb