diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-12-12 14:30:42 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-12-12 14:30:42 +0000 |
commit | 68218154e3ce4e5c4f13ed385cbc1d2231bb6a17 (patch) | |
tree | 36ca5e290fc127f9414b8cefc2353863c3c2ccb5 /lib/custodian | |
parent | ba26515587d1b5c5e645cf723cb9b89448df301d (diff) |
The suppression period varies between working and out of hours
Diffstat (limited to 'lib/custodian')
-rw-r--r-- | lib/custodian/alerts/mauve.rb | 40 |
1 files 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 |