summaryrefslogtreecommitdiff
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
commit6fc7fb140da4a66c54bba49ce41a9cff91a0594b (patch)
treebedc6ecc01bf0db03f917a512a1c3a8887f7318a
parent1292540651a2ba694320b795cd8dfab62b9b49f6 (diff)
Expire keys sanely.
-rw-r--r--debian/changelog6
-rw-r--r--lib/custodian/alerts/redis-state.rb13
2 files changed, 17 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index 25fbff0..6f7c697 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+custodian (0.6-2) stable; urgency=low
+
+ * Set an expiry time on the keys we add to redis.
+
+ -- Steve Kemp <steve@bytemark.co.uk> Tue, 27 Nov 2012 19:33:19 +0000
+
custodian (0.6-1) stable; urgency=low
* Added telnet protocol-test; some of our switches don't
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}" )