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.2.0rc2 lib/flapjack/filters/acknowledgement.rb
flapjack-1.2.0rc1 lib/flapjack/filters/acknowledgement.rb
flapjack-0.9.5 lib/flapjack/filters/acknowledgement.rb
flapjack-0.9.4 lib/flapjack/filters/acknowledgement.rb
flapjack-1.1.0 lib/flapjack/filters/acknowledgement.rb
flapjack-1.0.0 lib/flapjack/filters/acknowledgement.rb
flapjack-1.0.0rc6 lib/flapjack/filters/acknowledgement.rb
flapjack-1.0.0rc5 lib/flapjack/filters/acknowledgement.rb
flapjack-0.9.3 lib/flapjack/filters/acknowledgement.rb
flapjack-1.0.0rc3 lib/flapjack/filters/acknowledgement.rb
flapjack-1.0.0rc2 lib/flapjack/filters/acknowledgement.rb
flapjack-0.9.2 lib/flapjack/filters/acknowledgement.rb
flapjack-0.9.1 lib/flapjack/filters/acknowledgement.rb
flapjack-1.0.0rc1 lib/flapjack/filters/acknowledgement.rb
flapjack-0.9.0 lib/flapjack/filters/acknowledgement.rb
flapjack-0.8.12 lib/flapjack/filters/acknowledgement.rb
flapjack-0.8.11 lib/flapjack/filters/acknowledgement.rb
flapjack-0.8.10 lib/flapjack/filters/acknowledgement.rb
flapjack-0.8.9 lib/flapjack/filters/acknowledgement.rb
flapjack-0.8.8 lib/flapjack/filters/acknowledgement.rb