summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-13 09:55:24 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-13 09:55:24 +0000
commit2bcccfc4abd3ba15a9854b93ca40de1b4f715cc6 (patch)
tree87e14cc94507fe132a413678f43f61533f09540c
parent42803aeefdbb7c2f75bdea621294c10a0a9e41c4 (diff)
Use mauvealert to raise/clear alerts.
-rwxr-xr-xworker/worker41
1 files changed, 38 insertions, 3 deletions
diff --git a/worker/worker b/worker/worker
index c9ac743..6e4c9df 100755
--- a/worker/worker
+++ b/worker/worker
@@ -20,6 +20,8 @@ require 'beanstalk-client'
require 'getoptlong'
require 'json'
+require 'mauve/sender'
+require 'mauve/proto'
@@ -50,12 +52,45 @@ class Alert
@details = test_details
end
+
+ #
+ # Raise the alert.
+ #
def raise
- puts "RAISING ALERT: #{@details}"
+
+ update = Mauve::Proto::AlertUpdate.new
+ update.alert = []
+ update.source = "custodian"
+ update.replace = true
+
+ alert = Mauve::Proto::Alert.new
+ alert.id = @details['test_type']
+ alert.subject = "#{@details['test_host']} #{@details['test_alert']]"
+ alert.detail = "The test of type #{@details['test_type']} failed"
+ alert.raise_time = Time.now.to_i
+ update.alert << alert
+
+ Mauve::Sender.new("alert.bytemark.co.uk").send(update)
+
end
+ #
+ # Clear the alert.
+ #
def clear
- puts "CLEARING ALERT: #{@details}"
+ update = Mauve::Proto::AlertUpdate.new
+ update.alert = []
+ update.source = "custodian"
+ update.replace = true
+
+ alert = Mauve::Proto::Alert.new
+ alert.id = @details['test_type']
+ alert.subject = "#{@details['test_host']} #{@details['test_alert']]"
+ alert.detail = "The test of type #{@details['test_type']} failed"
+ alert.clear_time = Time.now.to_i
+ update.alert << alert
+
+ Mauve::Sender.new("alert.bytemark.co.uk").send(update)
end
end
@@ -215,7 +250,7 @@ end
#
if __FILE__ == $0 then
- $SERVER = "localhost:11300";
+ $SERVER = "127.0.0.1:11300";
begin
opts = GetoptLong.new(