class CarbonClient
Public Class Methods
new(hstr)
click to toggle source
# File lib/notify/graphite.rb, line 4 def initialize(hstr) @host, @port = hstr.split(":") @port = 2003 unless @port @port = @port.to_i end
Public Instance Methods
closeSocket()
click to toggle source
# File lib/notify/graphite.rb, line 16 def closeSocket @socket.close if @socket @socket = nil end
getSocket()
click to toggle source
# File lib/notify/graphite.rb, line 10 def getSocket STDOUT.puts @host @socket = TCPSocket.new(@host.to_s, @port) unless @socket && !@socket.closed? return @socket end
sendMetric(key, value, time = Time.now)
click to toggle source
# File lib/notify/graphite.rb, line 21 def sendMetric(key, value, time = Time.now) begin getSocket.puts("#{key} #{value.to_f} #{time.to_i}") rescue Errno::EPIPE, Errno::EHOSTUNREACH, Errno::EHOSTDOWN @socket = nil return nil end closeSocket if @socket end