summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/custodian/settings.rb26
-rw-r--r--lib/custodian/worker.rb13
2 files changed, 28 insertions, 11 deletions
diff --git a/lib/custodian/settings.rb b/lib/custodian/settings.rb
index 48adcc0..b601d79 100644
--- a/lib/custodian/settings.rb
+++ b/lib/custodian/settings.rb
@@ -54,6 +54,7 @@ module Custodian
val = $2.dup
key.strip!
val.strip!
+
@settings[key] = val
end
end
@@ -125,24 +126,31 @@ module Custodian
#
# When the alerter is "mauve" the target is the destination for the alerts.
#
- def alerter_target
+ def alerter_target( alert )
_load() unless( _loaded? )
+
+ #
+ # Find the alerting method.
+ #
# if we have something setup then use it.
- if ( @settings['alerter_target'] )
- return( @settings['alerter_target'] )
+ if ( @settings["#{alert}_target"] )
+ return( @settings["#{alert}_target"] )
+ else
end
# otherwise per-test defaults.
- case alerter()
- when "smtp":
+ case alert
+ when "smtp":
"root"
- when "mauve":
+ when "mauve":
"alert.bytemark.co.uk"
- when "file":
+ when "file":
"alerts.log"
- else
- nil
+ when "redis":
+ "127.0.0.1:6379"
+ else
+ nil
end
end
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb
index 57c55f7..79dab1e 100644
--- a/lib/custodian/worker.rb
+++ b/lib/custodian/worker.rb
@@ -213,9 +213,14 @@ module Custodian
#
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() )
+
+ target = Custodian::Settings.instance().alerter_target( alerter )
+ puts "Target for alert is #{target}"
+
+ alert.set_target( target )
alert.raise()
end
end
@@ -228,7 +233,11 @@ module Custodian
@alerter.split( "," ).each do |alerter|
log_message( "Creating alerter: #{alerter}" )
alert = Custodian::AlertFactory.create( alerter, test )
- alert.set_target( Custodian::Settings.instance().alerter_target() )
+
+ target = Custodian::Settings.instance().alerter_target( alerter )
+ puts "Target for alert is #{target}"
+
+ alert.set_target( target )
alert.clear()
end
end