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.7.14 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.13 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.12 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.11 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.10 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.9 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.8 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.7 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.6 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.5 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.4 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.3 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.2 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.1 lib/flapjack/filters/acknowledgement.rb
flapjack-0.7.0 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.61 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.60 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.59 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.58 lib/flapjack/filters/acknowledgement.rb
flapjack-0.6.57 lib/flapjack/filters/acknowledgement.rb