From 67e9647b9ff89c09a4ca7ab587e3f292c4a4c688 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 24 Jan 2013 11:58:35 +0000 Subject: Store the duration of tests. --- lib/custodian/alerts/redis-state.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'lib/custodian/alerts') 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" -- cgit v1.2.1