Class: Slurry::Graphite

Inherits:
Object
  • Object
show all
Defined in:
lib/slurry/graphite.rb

Overview

Handles connection details to the graphite server.

Instance Method Summary collapse

Constructor Details

#initialize(server, port) ⇒ Graphite

Opens a socket with the specified graphite server.

Parameters:

  • server (String)
  • port (String)


9
10
11
12
# File 'lib/slurry/graphite.rb', line 9

def initialize(server,port)
  @server, @port = server, port
  @s = TCPSocket.open(server,port)
end

Instance Method Details

#closeObject

Close the open socket to the graphite server.



25
26
27
# File 'lib/slurry/graphite.rb', line 25

def close
  @s.close
end

#send(target, value, time) ⇒ Object

Puts the graphite formatted string into the open socket.

Parameters:

  • target (String)

    the graphite formatted target in dotted notion

  • value (String)

    the value of the target

  • time (String)

    the time that the sample was taken



19
20
21
22
# File 'lib/slurry/graphite.rb', line 19

def send (target,value,time)
  line = [target,value,time].join(" ")
  @s.puts(line)
end