diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
commit | fd23821950f0562a8995735105cd31fdc6d55933 (patch) | |
tree | 967df2f5647803a6c46f4d52003b2231c1de72cb /lib/mauve/heartbeat.rb | |
parent | d3a3cfef9650b08f62db62bd7e86b673f9d77d0b (diff) |
* Rejigged configuration
* Added --test and --verbose flags for the server config
* Started proper test suite
* Config parsing now gives more sensible errors + backtrace
* Rejigged people and source lists
Diffstat (limited to 'lib/mauve/heartbeat.rb')
-rw-r--r-- | lib/mauve/heartbeat.rb | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/lib/mauve/heartbeat.rb b/lib/mauve/heartbeat.rb index 0f51f80..add0cdf 100644 --- a/lib/mauve/heartbeat.rb +++ b/lib/mauve/heartbeat.rb @@ -12,21 +12,38 @@ module Mauve include Singleton - attr_accessor :destination, :summary, :detail - attr_reader :sleep_interval, :raise_at + attr_reader :raise_after, :destination, :summary, :detail def initialize super @destination = nil - @summary = "Mauve alert server down." + @summary = "Mauve alert server heartbeat failed" @detail = "The Mauve server at #{Server.instance.hostname} has failed to send a heartbeat." - self.raise_at = 600 + @raise_after = 310 + @poll_every = 60 end - def raise_at=(i) - @raise_at = i - @sleep_interval = ((i.to_f)/2.5).round.to_i + def raise_after=(i) + raise ArgumentError "raise_after must be an integer" unless i.is_a?(Integer) + @raise_after = i + end + + alias send_every= poll_every= + + def summary=(s) + raise ArgumentError "summary must be a string" unless s.is_a?(String) + @summary = s + end + + def detail=(d) + raise ArgumentError "detail must be a string" unless d.is_a?(String) + @detail = d + end + + def destination=(d) + raise ArgumentError "destination must be a string" unless d.is_a?(String) + @destination = d end def logger @@ -49,12 +66,13 @@ module Mauve message.id = "mauve-heartbeat" message.summary = self.summary message.detail = self.detail - message.raise_time = (MauveTime.now.to_f+self.raise_at).to_i + message.raise_time = (MauveTime.now.to_f+self.raise_after).to_i message.clear_time = MauveTime.now.to_i update.alert << message Mauve::Sender.new(self.destination).send(update) + logger.debug "Sent to #{self.destination}" end end |