summaryrefslogtreecommitdiff
path: root/lib/custodian/alerts/redis-state.rb
diff options
context:
space:
mode:
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"