summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2013-10-04 15:03:55 +0100
committerSteve Kemp <steve@steve.org.uk>2013-10-04 15:03:55 +0100
commitcc19d2cb6f33a1c9c07d8b446888084c9ce88a33 (patch)
tree12f8134ab97f68052e1b68e4a0abf49eb3d0fc42 /lib
parent867a8a8248b46ef1dd2f9ff6874fb6ed771ef41f (diff)
Graphite alerter.
Diffstat (limited to 'lib')
-rw-r--r--lib/custodian/alerts.rb1
-rw-r--r--lib/custodian/alerts/graphite.rb70
2 files changed, 71 insertions, 0 deletions
diff --git a/lib/custodian/alerts.rb b/lib/custodian/alerts.rb
index 1f90fe2..d22419b 100644
--- a/lib/custodian/alerts.rb
+++ b/lib/custodian/alerts.rb
@@ -15,6 +15,7 @@ require 'custodian/alertfactory'
# The individual alert-types.
#
require 'custodian/alerts/file'
+require 'custodian/alerts/graphite'
require 'custodian/alerts/mauve'
require 'custodian/alerts/redis-state'
require 'custodian/alerts/smtp'
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