summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/custodian-dequeue2
-rw-r--r--lib/custodian/worker.rb27
2 files changed, 22 insertions, 7 deletions
diff --git a/bin/custodian-dequeue b/bin/custodian-dequeue
index 4e652ff..08579af 100755
--- a/bin/custodian-dequeue
+++ b/bin/custodian-dequeue
@@ -144,7 +144,7 @@ if __FILE__ == $0 then
#
# Create the object
#
- worker = Custodian::Worker.new( $SERVER, $ALERTER, $LOGFILE )
+ worker = Custodian::Worker.new( $SERVER, $ALERTER, $LOGFILE, settings )
#
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb
index 936c44b..11aa0e6 100644
--- a/lib/custodian/worker.rb
+++ b/lib/custodian/worker.rb
@@ -61,12 +61,18 @@ module Custodian
attr_reader :logger
+ #
+ # The settings from the global configuration file
+ #
+ attr_reader :settings
+
+
#
# Constructor: Connect to the queue
#
- def initialize( server, alerter, logfile )
+ def initialize( server, alerter, logfile, settings )
# Connect to the queue
@queue = Beanstalk::Pool.new([server], "Custodian" )
@@ -77,6 +83,9 @@ module Custodian
# Instantiate the logger.
@logger = Logger.new( logfile, "daily" )
+ # Save the settings
+ @settings = settings
+
# How many times to repeat a failing test
@retry_count=5
@@ -214,10 +223,13 @@ module Custodian
log_message( "Creating alerter: #{alerter}" )
alert = Custodian::AlertFactory.create( alerter, test )
- target = Custodian::Settings.instance().alerter_target( alerter )
+ target = @settings.alerter_target( alerter )
+ alert.set_target( target )
puts "Target for alert is #{target}"
- alert.set_target( target )
+ # give the alerter a reference to the settings object.
+ alert.set_settings( @settings )
+
alert.raise()
end
end
@@ -229,12 +241,15 @@ module Custodian
def do_clear( test )
@alerter.split( "," ).each do |alerter|
log_message( "Creating alerter: #{alerter}" )
- alert = Custodian::AlertFactory.create( alerter, test )
+ alert = Custodian::AlertFactory.create( alerter, test )
- target = Custodian::Settings.instance().alerter_target( alerter )
+ target = @settings.alerter_target( alerter )
+ alert.set_target( target )
puts "Target for alert is #{target}"
- alert.set_target( target )
+ # give the alerter a reference to the settings object.
+ alert.set_settings( @settings )
+
alert.clear()
end
end