From d48349ac70b2f79eff5ab53eaeb966d076ef89dd Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Fri, 4 Oct 2013 15:03:55 +0100 Subject: Graphite alerter. --- lib/custodian/alerts/graphite.rb | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lib/custodian/alerts/graphite.rb (limited to 'lib/custodian/alerts') diff --git a/lib/custodian/alerts/graphite.rb b/lib/custodian/alerts/graphite.rb new file mode 100644 index 0000000..857c872 --- /dev/null +++ b/lib/custodian/alerts/graphite.rb @@ -0,0 +1,70 @@ +# +# The graphite-alerter. +# +# This only exists to record timing durations in the local graphite/carbon +# instance. +# +module Custodian + + module Alerter + + class GraphiteAlert < AlertFactory + + # + # The test this alerter cares about + # + attr_reader :test + + + # + # Constructor - save the test-object away. + # + def initialize( obj ) + @test = obj + end + + + + # + # NOP. + # + def raise + end + + + + # + # NOP. + # + def clear + end + + + + # + # Send the test test-duration to graphite/carbon + # + def duration( ms ) + + # + # hostname + test-type + # + host = @test.target + test = @test.get_type + + # + # The key we'll send + # + str = "#{host}-#{test}" + str.gsub!(/\\\./, "-") + str = "monitor.#{str}" + + system( "/bin/echo '#{str} #{ms} #{Time.now.to_i}' | nc localhost 2003" ) + end + + register_alert_type "graphite" + + + end + end +end -- cgit v1.2.1