summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-12-12 14:30:42 +0000
committerSteve Kemp <steve@steve.org.uk>2012-12-12 14:30:42 +0000
commit52299ee344c5cebccf73433ef9f8ef36835e189f (patch)
tree90863217585869e405cd5b9237f001166b6b1928
parent450273c03912eb725e9216f4d741706855ecde99 (diff)
The suppression period varies between working and out of hours
-rw-r--r--lib/custodian/alerts/mauve.rb40
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