libratonator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in libratonator.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Michael Gorsuch
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ # Libratonator
2
+
3
+ Experimental CLI tool to pipe Graphite's Carbon data to Librato Metrics
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'libratonator'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install libratonator
18
+
19
+ ## Usage
20
+
21
+ Data is piped into `libratonator` formatted as the Graphite's [plaintext protocol](http://graphite.readthedocs.org/en/latest/feeding-carbon.html):
22
+
23
+ ```bash
24
+ # take standard Carbon data, pipe it to Librato
25
+ $ echo foo.measurement 12345 1348688087 | libratonator
26
+ ```
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'libratonator'
4
+
5
+ Libratonator::CLI.new.run
@@ -0,0 +1,5 @@
1
+ require 'librato/metrics'
2
+
3
+ require 'libratonator/cli'
4
+ require 'libratonator/parser'
5
+ require 'libratonator/version'
@@ -0,0 +1,18 @@
1
+ module Libratonator
2
+ class CLI
3
+ attr_reader :parser, :queue
4
+
5
+ def initialize
6
+ Librato::Metrics.authenticate ENV['LIBRATO_EMAIL'], ENV['LIBRATO_KEY']
7
+ @parser = Parser.new
8
+ @queue = Librato::Metrics::Queue.new(:autosubmit_interval => 60, :autosubmit_count => 400)
9
+ end
10
+
11
+ def run
12
+ ARGF.each_line do |l|
13
+ queue.add parser.parse(l)
14
+ end
15
+ queue.submit unless queue.size.zero?
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ module Libratonator
2
+ class Parser
3
+ def parse(s)
4
+ parts = s.split(' ')
5
+ {parts[0] => {'value' => parts[1], 'measure_time' => parts[2]}}
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module Libratonator
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/libratonator/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Michael Gorsuch"]
6
+ gem.email = ["michael.gorsuch@gmail.com"]
7
+ gem.description = %q{Experimental CLI tool to pipe Graphite's Carbon data to Librato Metrics}
8
+ gem.summary = gem.description
9
+ gem.homepage = "https://github.com/gorsuch/libratonator"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "libratonator"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Libratonator::VERSION
17
+ gem.add_development_dependency('rake')
18
+ gem.add_development_dependency('rspec')
19
+ gem.add_dependency('librato-metrics')
20
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Libratonator::Parser do
4
+ describe '#parse' do
5
+ let(:parser) { Libratonator::Parser.new }
6
+ let(:sample) { 'foo 12345 67890' }
7
+
8
+ it 'should return a hash' do
9
+ parser.parse(sample).should be_kind_of(Hash)
10
+ end
11
+
12
+ it 'should return a hash with the metric name as the key' do
13
+ parser.parse(sample).keys.first.should eq('foo')
14
+ end
15
+
16
+ it 'should return a hash with only one key' do
17
+ parser.parse(sample).keys.size.should eq(1)
18
+ end
19
+
20
+ it 'should give a hash that includes the value' do
21
+ parser.parse(sample)['foo'].should have_key('value')
22
+ parser.parse(sample)['foo']['value'].should eq('12345')
23
+ end
24
+
25
+ it 'should give a hash that includes the measure_time' do
26
+ parser.parse(sample)['foo'].should have_key('measure_time')
27
+ parser.parse(sample)['foo']['measure_time'].should eq('67890')
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,8 @@
1
+ require 'libratonator'
2
+
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run :focus
7
+ config.order = 'random'
8
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libratonator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Gorsuch
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70219004379760 !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: *70219004379760
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70219004379340 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70219004379340
36
+ - !ruby/object:Gem::Dependency
37
+ name: librato-metrics
38
+ requirement: &70219004378860 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70219004378860
47
+ description: Experimental CLI tool to pipe Graphite's Carbon data to Librato Metrics
48
+ email:
49
+ - michael.gorsuch@gmail.com
50
+ executables:
51
+ - libratonator
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .rspec
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - bin/libratonator
62
+ - lib/libratonator.rb
63
+ - lib/libratonator/cli.rb
64
+ - lib/libratonator/parser.rb
65
+ - lib/libratonator/version.rb
66
+ - libratonator.gemspec
67
+ - spec/libratonator/parser_spec.rb
68
+ - spec/spec_helper.rb
69
+ homepage: https://github.com/gorsuch/libratonator
70
+ licenses: []
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ segments:
82
+ - 0
83
+ hash: -1442235635612830453
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ segments:
91
+ - 0
92
+ hash: -1442235635612830453
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 1.8.10
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: Experimental CLI tool to pipe Graphite's Carbon data to Librato Metrics
99
+ test_files:
100
+ - spec/libratonator/parser_spec.rb
101
+ - spec/spec_helper.rb