summaryrefslogtreecommitdiff
path: root/lib/custodian/alerts/redis-state.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2013-01-24 11:58:35 +0000
committerSteve Kemp <steve@steve.org.uk>2013-01-24 11:58:35 +0000
commit4ae68ec3f54f4803f3e8694bc9ede0964b849e09 (patch)
treee3519572826c70195ba4ddc3ec44604a4d0a242d /lib/custodian/alerts/redis-state.rb
parent15b8c976ddd6401b9f3afaedbcf4af368cd34359 (diff)
Store the duration of tests.
Diffstat (limited to 'lib/custodian/alerts/redis-state.rb')
-rw-r--r--lib/custodian/alerts/redis-state.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/custodian/alerts/redis-state.rb b/lib/custodian/alerts/redis-state.rb
index 88b005a..d2c525d 100644
--- a/lib/custodian/alerts/redis-state.rb
+++ b/lib/custodian/alerts/redis-state.rb
@@ -103,6 +103,38 @@ module Custodian
+ #
+ # Store a test-duration in redis
+ #
+ def duration( ms )
+
+ return unless( @redis )
+
+ #
+ # hostname + test-type
+ #
+ host = @test.target
+ test = @test.get_type
+
+ #
+ # Store the host.
+ #
+ # make sure this alert is discoverable
+ @redis.sadd( "duration-hosts", host )
+
+ #
+ # Store the test.
+ #
+ @redis.sadd( "duration-host-#{host}", test )
+
+ #
+ # Now store the duration, and trim it to the most recent
+ # 1000 entries.
+ #
+ @redis.lpush( "#{host}-#{test}", ms )
+ @redis.ltrim( "#{host}-#{test}", "0", "1200" )
+ end
+
register_alert_type "redis"