summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-26 11:04:54 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-26 11:04:54 +0000
commitc6e8287abf523721b855e0878380c2fc12df9a8c (patch)
tree21688449e1f18f2dbfbae3856110322966711da1
parentfd80dc9a045e9c939bfb722d2d74a0c379aa4ac8 (diff)
Allow multiple alerters.
-rw-r--r--lib/custodian/worker.rb45
1 files changed, 27 insertions, 18 deletions
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb
index bdafb9d..57c55f7 100644
--- a/lib/custodian/worker.rb
+++ b/lib/custodian/worker.rb
@@ -155,22 +155,6 @@ module Custodian
test = Custodian::TestFactory.create( body )
- #
- # As a result of this test we'll either raise/clear with one
- # of our alerter classes.
- #
- # Here we create one of the correct type.
- #
- alert = Custodian::AlertFactory.create( @alerter, test )
-
- #
- # Set the target for the alert, which might be nil.
- #
- alert.set_target( Custodian::Settings.instance().alerter_target() )
-
-
-
-
#
# We'll run no more than MAX times.
@@ -189,8 +173,8 @@ module Custodian
if ( result )
log_message( "Test succeeed - clearing alert" )
+ do_clear( test )
success = true
- alert.clear()
end
count += 1
end
@@ -204,7 +188,7 @@ module Custodian
# Raise the alert, passing the error message.
#
log_message( "Test failed - alerting with #{test.error()}" )
- alert.raise()
+ do_raise( test )
end
rescue => ex
@@ -224,6 +208,31 @@ module Custodian
end
+ #
+ # Raise an alert, with each registered alerter.
+ #
+ def do_raise( test )
+ @alerter.split( "," ).each do |alerter|
+ log_message( "Creating alerter: #{alerter}" )
+ alert = Custodian::AlertFactory.create( alerter, test )
+ alert.set_target( Custodian::Settings.instance().alerter_target() )
+ alert.raise()
+ end
+ end
+
+
+ #
+ # Clear an alert, with each registered alerter.
+ #
+ def do_clear( test )
+ @alerter.split( "," ).each do |alerter|
+ log_message( "Creating alerter: #{alerter}" )
+ alert = Custodian::AlertFactory.create( alerter, test )
+ alert.set_target( Custodian::Settings.instance().alerter_target() )
+ alert.clear()
+ end
+ end
+
#