Sha256: 7c9f921736590c1628d6e5ce5466f57c504a447a92ac464cc9746f6a20c1fc2a

Contents?: true

Size: 1.38 KB

Versions: 58

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby

require 'flapjack/filters/base'

module Flapjack
  module Filters
    # * If the action event’s state is an acknowledgement, and the corresponding check is in a
    #   failure state, then set unscheduled maintenance for 4 hours on the check
    # * If the action event’s state is an acknowledgement, and the corresponding check is not in a
    #   failure state, then don’t alert
    class Acknowledgement
      include Base

      def block?(event, entity_check, previous_state)
        timestamp = Time.now.to_i

        label = 'Filter: Acknowledgement:'

        return false unless event.type == 'action'

        unless event.acknowledgement?
          @logger.debug("#{label} pass (not an ack)")
          return false
        end

        if entity_check.nil?
          @logger.error "#{label} unknown entity for event '#{event.id}'"
          return false
        end

        unless @redis.zscore("failed_checks", event.id)
          @logger.debug("#{label} blocking because zscore of failed_checks for #{event.id} is false")
          return true
        end

        um_duration = event.duration || (4 * 60 * 60)
        entity_check.create_unscheduled_maintenance(timestamp, um_duration, :summary  => event.summary)

        @logger.debug("#{label} pass (unscheduled maintenance created for #{event.id}, duration: #{um_duration})")
        false
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
flapjack-1.6.0 lib/flapjack/filters/acknowledgement.rb
flapjack-1.6.0rc4 lib/flapjack/filters/acknowledgement.rb
flapjack-1.6.0rc3 lib/flapjack/filters/acknowledgement.rb
flapjack-1.6.0rc2 lib/flapjack/filters/acknowledgement.rb
flapjack-1.6.0rc1 lib/flapjack/filters/acknowledgement.rb
flapjack-1.5.0 lib/flapjack/filters/acknowledgement.rb
flapjack-1.5.0rc1 lib/flapjack/filters/acknowledgement.rb
flapjack-1.4.0 lib/flapjack/filters/acknowledgement.rb
flapjack-1.4.0rc1 lib/flapjack/filters/acknowledgement.rb
flapjack-1.3.0 lib/flapjack/filters/acknowledgement.rb
flapjack-1.3.0rc3 lib/flapjack/filters/acknowledgement.rb
flapjack-1.3.0rc2 lib/flapjack/filters/acknowledgement.rb
flapjack-1.3.0rc1 lib/flapjack/filters/acknowledgement.rb
flapjack-1.2.2 lib/flapjack/filters/acknowledgement.rb
flapjack-1.2.1 lib/flapjack/filters/acknowledgement.rb
flapjack-1.2.1rc3 lib/flapjack/filters/acknowledgement.rb
flapjack-1.2.1rc2 lib/flapjack/filters/acknowledgement.rb
flapjack-1.2.1rc1 lib/flapjack/filters/acknowledgement.rb
flapjack-1.2.0 lib/flapjack/filters/acknowledgement.rb
flapjack-0.9.6 lib/flapjack/filters/acknowledgement.rb