diff options
author | Steve Kemp <steve@steve.org.uk> | 2013-10-08 09:55:26 +0100 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2013-10-08 09:55:26 +0100 |
commit | 942dec719333ee6a7fd0f46fb9f5f64c390ffe2e (patch) | |
tree | c2b08c03b2140d9ff37c28394d5e5e56a76201a5 /lib/custodian/alerts | |
parent | 3961a0bf3e1ef5367056223989c03669a090f50b (diff) |
Updated to send via UDP, without system.
Diffstat (limited to 'lib/custodian/alerts')
-rw-r--r-- | lib/custodian/alerts/graphite.rb | 23 |
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" |