diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-26 15:05:18 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-26 15:05:18 +0000 |
commit | d79f8f76d1b8a0940814f41760f1387d0e1364d9 (patch) | |
tree | c12309e956ad1b0f1fb0d0536c82bad0ea206d2d /lib/custodian/alerts/redis-state.rb | |
parent | 62741cbbb0df2bfe040063f9a04670f09b5a9363 (diff) |
Don't attempt to raise/clear with redis/mauve unless they were loaded.
Diffstat (limited to 'lib/custodian/alerts/redis-state.rb')
-rw-r--r-- | lib/custodian/alerts/redis-state.rb | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/lib/custodian/alerts/redis-state.rb b/lib/custodian/alerts/redis-state.rb index b2243f7..38b592e 100644 --- a/lib/custodian/alerts/redis-state.rb +++ b/lib/custodian/alerts/redis-state.rb @@ -14,35 +14,38 @@ module Custodian class RedisAlert < AlertFactory + # # The test this alerter cares about # attr_reader :test + # # The redis-object # attr_reader :redis - attr_reader :available + + # # Constructor - save the test-object away & instantiate # the redis connection. # def initialize( obj ) - @available = true - - begin - require 'rubygems' - require 'redis' - rescue - puts "LOADING redis failed" - @available = false - end - - @test = obj - @redis = Redis.new( ) if ( @available ) + + begin + require 'rubygems' + require 'redis' + + @redis = Redis.new() + + rescue + puts "ERROR Loading redis rubygem!" + end + + @test = obj end @@ -51,7 +54,9 @@ module Custodian # Store an alert in redis # def raise - return if ( ! @available ) + + return unless( @redis ) + # hostname + test-type host = @test.target @@ -71,7 +76,9 @@ module Custodian # Clear an alert in redis # def clear - return if ( ! @available ) + + return unless( @redis ) + # hostname + test-type host = @test.target |