Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Unworking version of the 'metric' method. Not sure why yet.

  • Loading branch information...
commit ee5b6792c8f197cb9cf92a6c89d8e97a31839a2e 1 parent d14faea
Josh Kleinpeter authored
Showing with 24 additions and 2 deletions.
  1. +6 −0 Rakefile
  2. +1 −0  lib/continuum.rb
  3. +17 −2 lib/continuum/client.rb
View
6 Rakefile
@@ -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
View
1  lib/continuum.rb
@@ -1,5 +1,6 @@
require 'hugs'
require 'json'
+require 'socket'
require 'continuum/client'
## Continuum
View
19 lib/continuum/client.rb
@@ -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
)
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.