Sha256: 28635877865700ff3ad2c10ac992f9a93a276574beb0c47699fada2ed1789c9c

Contents?: true

Size: 1.62 KB

Versions: 37

Compression:

Stored size: 1.62 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)
        timestamp = Time.now.to_i
        result = false
        if event.type == 'action'
          if event.acknowledgement?
            if @persistence.zscore("failed_checks", event.id)
              ec = Flapjack::Data::EntityCheck.for_event_id(event.id, :redis => @persistence)
              if ec.nil?
                @log.error "Filter: Acknowledgement: unknown entity for event '#{event.id}'"
              else
                ec.create_unscheduled_maintenance(:start_time => timestamp,
                  :duration => (event.duration || (4 * 60 * 60)),
                  :summary  => event.summary)
                message = "unscheduled maintenance created for #{event.id}"
              end
            else
              result = true
              @log.debug("Filter: Acknowledgement: blocking because zscore of failed_checks for #{event.id} is false") unless @persistence.zscore("failed_checks", event.id)
            end
          else
            message = "no action taken"
            result  = false
          end
        end
        @log.debug("Filter: Acknowledgement: #{result ? "block" : "pass"} (#{message})")
        result
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
flapjack-0.6.56 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.55 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.54 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.53 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.52 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.51 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.50 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.49 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.48 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.47 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.46 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.45 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.44 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.43 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.42 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.41 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.40 lib/flapjack/filters/acknowledgement.rb