summaryrefslogtreecommitdiff
path: root/lib/custodian
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-27 19:37:00 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-27 19:37:00 +0000
commit8bffb2556c98150e34317a169bb60a628ed9a802 (patch)
treec8cc195a35592f7b6f623f00975c1809a2906d27 /lib/custodian
parent439eb2c01203845ed55388f51b4ca68899e500f3 (diff)
Expire keys sanely.
Diffstat (limited to 'lib/custodian')
-rw-r--r--lib/custodian/alerts/redis-state.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/custodian/alerts/redis-state.rb b/lib/custodian/alerts/redis-state.rb
index ae62dc3..88b005a 100644
--- a/lib/custodian/alerts/redis-state.rb
+++ b/lib/custodian/alerts/redis-state.rb
@@ -62,9 +62,13 @@ module Custodian
host = @test.target
test = @test.get_type
- # store the error
+ # store the error - set an expiry time of 5 minutes
@redis.set( "#{host}-#{test}", "ERR")
+ @redis.expireat( "#{host}-#{test}", Time.now.to_i + 5 * 60 )
+
+ # Set the reason
@redis.set( "#{host}-#{test}-reason", @test.error() )
+ @redis.expireat( "#{host}-#{test}-reason", Time.now.to_i + 5 * 60 )
# make sure this alert is discoverable
@redis.sadd( "hosts", "#{host}-#{test}" )
@@ -84,9 +88,14 @@ module Custodian
host = @test.target
test = @test.get_type
- # store the OK
+ # store the OK - set the expiry time of five minutes
@redis.set( "#{host}-#{test}", "OK")
+ @redis.expireat( "#{host}-#{test}", Time.now.to_i + 5 * 60 )
+
+ # clear the reason
@redis.set( "#{host}-#{test}-reason", "")
+ @redis.expireat( "#{host}-#{test}-reason", Time.now.to_i + 5 * 60 )
+
# make sure this alert is discoverable
@redis.sadd( "hosts", "#{host}-#{test}" )