diff options
-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" |