From fd98b9e26fcc77300ec3bd92a472f16575e812fc Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 20 Sep 2017 09:25:34 +0300 Subject: Added a User-Agent to our HTTP/HTTPS checks. --- lib/custodian/protocoltest/http.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/custodian') diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb index 0bf1a68..5f013df 100644 --- a/lib/custodian/protocoltest/http.rb +++ b/lib/custodian/protocoltest/http.rb @@ -360,6 +360,9 @@ module Custodian c = Curl::Easy.new(test_url) + # setup a user-agent. + c.headers["User-Agent"] = "custodian/protocol-tester" + c.resolve_mode = resolve_mode # -- cgit v1.2.1 From d53221f7c976721ac1fc7aaff3607dbd71fb927e Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 20 Sep 2017 09:30:12 +0300 Subject: Update our metric-submission. We'll want to handle timeouts more cleanly now, and use TCP. --- lib/custodian/alerts/graphite.rb | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'lib/custodian') diff --git a/lib/custodian/alerts/graphite.rb b/lib/custodian/alerts/graphite.rb index 0244047..cca5ece 100644 --- a/lib/custodian/alerts/graphite.rb +++ b/lib/custodian/alerts/graphite.rb @@ -1,4 +1,5 @@ require 'socket' +require 'timeout' # # The graphite-alerter. @@ -61,12 +62,25 @@ module Custodian payload = "custodian.#{test}.#{host}.test_duration_ms #{ms} #{Time.now.to_i}" # - # Send via UDP. + # Send metrics via TCP. # - socket = UDPSocket.new - socket.send(payload, 0, @target, 2003) - socket.close - + begin + Timeout.timeout(10) do + begin + socket = TCPSocket.new(@target,2003) + puts payload + socket.write(payload) + socket.flush + socket.close + rescue Errno::ENETUNREACH + puts("Metrics host unreachable: #{e}") + rescue StandardError => e + puts("Error submitting metrics: #{e}") + end + end + rescue Timeout::Error + puts('Timeout submitting metrics') + end end register_alert_type 'graphite' -- cgit v1.2.1