From 68218154e3ce4e5c4f13ed385cbc1d2231bb6a17 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 12 Dec 2012 14:30:42 +0000 Subject: The suppression period varies between working and out of hours --- lib/custodian/alerts/mauve.rb | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/custodian/alerts/mauve.rb b/lib/custodian/alerts/mauve.rb index c0d4caf..a467215 100644 --- a/lib/custodian/alerts/mauve.rb +++ b/lib/custodian/alerts/mauve.rb @@ -83,9 +83,45 @@ module Custodian alert.raise_time = Time.now.to_i # - # We're going to suppress this alert for 7 minutes to suppress flaps. + # The supression period varies depending on the time of day. # - alert.suppress_until = Time.now.to_i + 420 + hour = Time.now.hour + wday = Time.now.wday + + # + # Is this inside the working day? + # + working = false + + # + # Lookup the start of the day. + # + day_start = @settings.key( "day_start" ) || 10 + day_end = @settings.key( "day_end" ) || 18 + + # + # If we're Monday-Friday, between the start & end time, then + # we're in the working day. + # + if ( ( ( wday != 0 ) && ( wday != 6 ) ) && + ( hour >= day_start && < day_end ) ) + working = true + end + + # + # The suppression period can now be determined. + # + period = working ? 4 : 10 + + # + # And logged. + # + puts "Suppression period is #{period}m" + + # + # We're going to suppress this alert now + # + alert.suppress_until = Time.now.to_i + ( period * 60 ) # # Update it and send it -- cgit v1.2.1