Class: Graphite_sender
- Inherits:
-
Object
- Object
- Graphite_sender
- Defined in:
- lib/graphite_sender.rb
Instance Method Summary collapse
-
#initialize(host, port = 2003, type = 'tcp') ⇒ Graphite_sender
constructor
A new instance of Graphite_sender.
- #send_measure(stat, value, timestamp = nil) ⇒ Object
Constructor Details
#initialize(host, port = 2003, type = 'tcp') ⇒ Graphite_sender
Returns a new instance of Graphite_sender.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/graphite_sender.rb', line 4 def initialize(host, port = 2003, type = 'tcp') @type = type if @type == 'tcp' @socket = TCPSocket.new(host, port) else @socket = UDPSocket.new @socket.connect(host, port) end end |
Instance Method Details
#send_measure(stat, value, timestamp = nil) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/graphite_sender.rb', line 16 def send_measure(stat, value, = nil) if == nil = Time.now.to_i end send_to_socket("#{stat} #{value} #{}") end |