Skip to content

Commit

Permalink
Unworking version of the 'metric' method. Not sure why yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Kleinpeter committed May 13, 2011
1 parent d14faea commit ee5b679
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ Bundler::GemHelper.install_tasks
task :irb do
exec 'irb -I.:lib -rubygems -rcontinuum'
end

task :autotest do
exec 'autotest -b'
end

task :default= => :test
1 change: 1 addition & 0 deletions lib/continuum.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'hugs'
require 'json'
require 'socket'
require 'continuum/client'

## Continuum
Expand Down
19 changes: 17 additions & 2 deletions lib/continuum/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ class Client
#
# A client to play with
def initialize host = '127.0.0.1', port = 4242
@host = host
@port = port
@client = Hugs::Client.new(
:host => host,
:port => port,
:host => @host,
:port => @port,
:scheme => 'http',
:type => :none
)
Expand Down Expand Up @@ -113,6 +115,19 @@ def suggest query, type = 'metrics'
JSON.parse response.body
end

# Format
# put <metric> <tisse> <value> host=<hostname>
# put proc.loadavg.5m 1305308654 0.01 host=i-00000106
def metric name, value
message = "put #{name} #{Time.now.to_i} #{value} host=#{Socket.gethostname}"

socket = TCPSocket.new @host, @port
socket.write message
socket.close

message
end

# Returns the version of OpenTSDB
#
# Returns
Expand Down

0 comments on commit ee5b679

Please sign in to comment.