Sha256: 506efa426bdee33dacc66b439b1c5b3ee6d18d594b6efae80177eda3d791f370
Contents?: true
Size: 1.61 KB
Versions: 13
Compression:
Stored size: 1.61 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? and @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))) message = "unscheduled maintenance created for #{event.id}" end else message = "no action taken" result = true @log.debug("Filter: Acknowledgement: blocking because event.acknowledgement? is false") unless event.acknowledgement? @log.debug("Filter: Acknowledgement: blocking because zscore of failed_checks for #{event.id} is false") unless @persistence.zscore("failed_checks", event.id) end end @log.debug("Filter: Acknowledgement: #{result ? "block" : "pass"} (#{message})") result end end end end
Version data entries
13 entries across 13 versions & 1 rubygems