summaryrefslogtreecommitdiff
path: root/lib/custodian
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2013-10-08 09:55:26 +0100
committerSteve Kemp <steve@steve.org.uk>2013-10-08 09:55:26 +0100
commitc6b20011447f913c918d9291dbd7d0da4a32e09e (patch)
tree7026339e6fdd27aec7881e01cba88e14c703d1e5 /lib/custodian
parent23a0d45199ae409b6e463546bba74b3d653305cf (diff)
Updated to send via UDP, without system.
Diffstat (limited to 'lib/custodian')
-rw-r--r--lib/custodian/alerts/graphite.rb23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/custodian/alerts/graphite.rb b/lib/custodian/alerts/graphite.rb
index abea54d..bc87beb 100644
--- a/lib/custodian/alerts/graphite.rb
+++ b/lib/custodian/alerts/graphite.rb
@@ -1,8 +1,11 @@
+require 'socket'
+
#
# The graphite-alerter.
#
-# This only exists to record timing durations in the local graphite/carbon
-# instance.
+# This only exists to record timing durations in the local
+# graphite/carbon instance. Updates are sent via UDP
+# to localhost:2003.
#
module Custodian
@@ -50,16 +53,22 @@ module Custodian
# hostname + test-type
#
host = @test.target
+ host.gsub!(/[\/\\.]/, "_")
test = @test.get_type
#
- # The key we'll send
+ # The payload
+ #
+ str = "#{test}.#{host}"
+ payload = "monitor.#{str} #{ms} #{Time.now.to_i}"
+
+ #
+ # Send via UDP.
#
- str = "#{test}-#{host}"
- str.gsub!(/[\/\\.]/, "-")
- str = "monitor.#{str}"
+ socket = UDPSocket.new()
+ socket.send( payload, 0, "localhost", 2003 );
+ socket.close()
- system( "/bin/echo '#{str} #{ms} #{Time.now.to_i}' | nc localhost 2003 -q1" )
end
register_alert_type "graphite"