opentsdb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +8 -0
- data/LICENSE +21 -0
- data/README.md +22 -0
- data/Rakefile +19 -0
- data/autotest/discover.rb +3 -0
- data/examples/client.rb +8 -0
- data/lib/opentsdb.rb +15 -0
- data/lib/opentsdb/client.rb +28 -0
- data/lib/opentsdb/logging.rb +19 -0
- data/lib/opentsdb/version.rb +3 -0
- data/opentsdb.gemspec +24 -0
- data/spec/client_spec.rb +11 -0
- data/spec/spec_helper.rb +16 -0
- metadata +100 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm ruby-1.9.3@opentsdb
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2012 John Ewart
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
## What is this?
|
3
|
+
|
4
|
+
This is a Ruby client for simplifying interactions with OpenTSDB
|
5
|
+
|
6
|
+
## What does it do?
|
7
|
+
|
8
|
+
As of this instant, not a whole lot except wrap the "put" method in a
|
9
|
+
quick-and-dirty style. This will eventually grow to be much more useful
|
10
|
+
as I expand functionality.
|
11
|
+
|
12
|
+
## Quick example
|
13
|
+
|
14
|
+
@client = OpenTSDB::Client.new({:hostname => 'localhost', :port => 4242})
|
15
|
+
|
16
|
+
sample = { :metric => 'double_rainbow.count', :value => 42, :timestamp => Time.now.to_i, :tags => {:factor => 'awesome', :host => 'ponies' } }
|
17
|
+
@client.put(sample)
|
18
|
+
|
19
|
+
|
20
|
+
## License
|
21
|
+
|
22
|
+
Copyright 2012 John Ewart <john@johnewart.net>. Released under the MIT license. See the file LICENSE for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler"
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
$stderr.puts e.message
|
10
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec::Core::RakeTask.new do |t|
|
15
|
+
t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
|
16
|
+
t.pattern = 'spec/**/*_spec.rb'
|
17
|
+
end
|
18
|
+
|
19
|
+
task :default => :spec
|
data/examples/client.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
$:.unshift File.dirname(__FILE__) + "/../lib"
|
3
|
+
require 'opentsdb'
|
4
|
+
|
5
|
+
@client = OpenTSDB::Client.new({:hostname => 'localhost', :port => 4242})
|
6
|
+
|
7
|
+
sample = { :metric => 'double_rainbow.count', :value => 42, :timestamp => Time.now.to_i, :tags => {:factor => 'awesome', :host => 'ponies' } }
|
8
|
+
@client.put(sample)
|
data/lib/opentsdb.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'opentsdb/logging'
|
3
|
+
|
4
|
+
module OpenTSDB
|
5
|
+
class Client
|
6
|
+
include Logging
|
7
|
+
|
8
|
+
attr_reader :connection
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
begin
|
12
|
+
hostname = options[:hostname] || 'localhost'
|
13
|
+
port = options[:port] || 4242
|
14
|
+
@connection = TCPSocket.new(hostname, port)
|
15
|
+
rescue
|
16
|
+
raise "Unable to connect or invalid connection data"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def put(options = {})
|
21
|
+
timestamp = options[:timestamp].to_i
|
22
|
+
metric_name = options[:metric]
|
23
|
+
value = options[:value].to_f
|
24
|
+
tags = options[:tags].map{|k,v| "#{k}=#{v}"}.join(" ")
|
25
|
+
@connection.puts("put #{metric_name} #{timestamp} #{value} #{tags}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/opentsdb.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "opentsdb/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "opentsdb"
|
7
|
+
s.version = OpenTSDB::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["John Ewart"]
|
10
|
+
s.email = ["john@johnewart.net"]
|
11
|
+
s.homepage = "https://github.com/johnewart/opentsdb"
|
12
|
+
s.summary = %q{Ruby client for OpenTSDB}
|
13
|
+
s.description = %q{A Ruby implementation of a client library for sending data points to OpenTSDB}
|
14
|
+
|
15
|
+
s.rubyforge_project = "opentsdb"
|
16
|
+
|
17
|
+
s.add_development_dependency "rspec"
|
18
|
+
s.add_development_dependency "simplecov", [">= 0.3.8"] #, :require => false
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
end
|
data/spec/client_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter "/spec/"
|
5
|
+
merge_timeout 3600
|
6
|
+
end
|
7
|
+
|
8
|
+
$:.unshift(File.expand_path('../../lib', __FILE__))
|
9
|
+
require 'opentsdb'
|
10
|
+
|
11
|
+
OpenTSDB.logger = Logger.new(STDERR)
|
12
|
+
OpenTSDB.logger.level = Logger::INFO
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.mock_with :rspec
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opentsdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Ewart
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: simplecov
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.3.8
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.3.8
|
46
|
+
description: A Ruby implementation of a client library for sending data points to
|
47
|
+
OpenTSDB
|
48
|
+
email:
|
49
|
+
- john@johnewart.net
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- .rvmrc
|
56
|
+
- CHANGELOG.md
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- autotest/discover.rb
|
62
|
+
- examples/client.rb
|
63
|
+
- lib/opentsdb.rb
|
64
|
+
- lib/opentsdb/client.rb
|
65
|
+
- lib/opentsdb/logging.rb
|
66
|
+
- lib/opentsdb/version.rb
|
67
|
+
- opentsdb.gemspec
|
68
|
+
- spec/client_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
homepage: https://github.com/johnewart/opentsdb
|
71
|
+
licenses: []
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
hash: 2858159892827198430
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
hash: 2858159892827198430
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project: opentsdb
|
96
|
+
rubygems_version: 1.8.24
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Ruby client for OpenTSDB
|
100
|
+
test_files: []
|