diff options
author | Steve Kemp <steve@steve.org.uk> | 2013-01-24 11:58:35 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2013-01-24 11:58:35 +0000 |
commit | 67e9647b9ff89c09a4ca7ab587e3f292c4a4c688 (patch) | |
tree | ea87b9d38a04784558a89a8a05d03c30112a07fe | |
parent | 5ae1e6944143acaf6cdc755b7178af827c5913c2 (diff) |
Store the duration of tests.
-rw-r--r-- | lib/custodian/alerts/redis-state.rb | 32 |
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" |