diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:54 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:54 +0100 |
commit | 25b32914b72a5f709eca773f3511cc89c2e710c2 (patch) | |
tree | 4dab9e78e4c6b49220a837b38d463328c05e2983 /lib/mauve/heartbeat.rb | |
parent | 3185e5d746abda1b7f42ecdbd74ec14359fda3bc (diff) | |
parent | fd23821950f0562a8995735105cd31fdc6d55933 (diff) |
merge
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 |