fluent-plugin-resque_stat 0.0.1

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 ADDED
@@ -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/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ matrix:
7
+ allow_failures:
8
+ - rvm: 2.0.0
9
+
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-resque-stat.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rspec'
8
+ gem 'rspec-core'
9
+ gem 'rake'
10
+ end
11
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Spring_MT
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.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Fluent::Plugin::ResqueStat [![Build Status](https://travis-ci.org/SpringMT/fluent-plugin-resque_stat.png)](https://travis-ci.org/SpringMT/fluent-plugin-resque_stat)
2
+
3
+ Fluent input plugin for Resque info
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fluent-plugin-resque_stat'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fluent-plugin-resque_stat
18
+
19
+ ## Configuration
20
+
21
+ ```
22
+ <source>
23
+ type resque_stat
24
+ tag resque
25
+ host 127.0.0.1
26
+ port 6379
27
+ run_interval 1s
28
+ </source>
29
+ ```
30
+ ## Output Format
31
+
32
+ Sample
33
+ {:pending=>0, :processed=>46, :queues=>1, :workers=>0, :working=>0, :failed=>0, :servers=>["redis://:6379/0"], :environment=>"development"}
34
+
35
+ Record
36
+
37
+ ```json
38
+ {
39
+ "pending": 0,
40
+ "processed": 46,
41
+ "queues": 1,
42
+ "workers": 0,
43
+ "working": 0,
44
+ "failed": 0,
45
+ "servers": "[\"redis://:6379/0\"]",
46
+ "environment": "development"
47
+ }
48
+ ```
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
57
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ task :default => :test
4
+
5
+ task :test do
6
+ require 'rspec/core'
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:test) do |spec|
9
+ spec.pattern = FileList['spec/**/*_spec.rb']
10
+ end
11
+ end
12
+
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "fluent-plugin-resque_stat"
7
+ gem.version = "0.0.1"
8
+ gem.authors = ["Spring_MT"]
9
+ gem.email = ["today.is.sky.blue.sky@gmail.com"]
10
+ gem.summary = %q{Fluent input plugin for Resque info}
11
+ gem.homepage = "https://github.com/SpringMT/fluent-plugin-resque_stat"
12
+
13
+ gem.rubyforge_project = "fluent-plugin-resque_stat"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "resque", "~> 1.22"
21
+ gem.add_dependency "fluentd"
22
+ gem.description = <<description
23
+ Fluent input plugin for Resque info
24
+ description
25
+ end
@@ -0,0 +1,55 @@
1
+ module Fluent
2
+ class ResqueStatInput < Input
3
+ Plugin.register_input('resque_stat', self)
4
+
5
+ def initialize
6
+ super
7
+ require 'resque'
8
+ end
9
+
10
+ config_param :tag, :string, :default => nil
11
+ config_param :host, :string, :default => '127.0.0.1'
12
+ config_param :port, :integer, :default => 6379
13
+ config_param :run_interval, :time, :default => 60
14
+
15
+ def configure(conf)
16
+ super
17
+ if !@tag
18
+ raise ConfigError, "'tag' option is required on exec input"
19
+ end
20
+ Resque.redis = "#{@hosts}:#{@port}"
21
+ end
22
+
23
+ def start
24
+ @finished = false
25
+ @thread = Thread.new(&method(:run_resque_stat))
26
+ end
27
+
28
+ def shutdown
29
+ @finished = true
30
+ @thread.join
31
+ end
32
+
33
+ def run_resque_stat
34
+ until @finished
35
+ sleep @run_interval
36
+ resque_each_line
37
+ end
38
+ end
39
+
40
+ private
41
+ def resque_each_line
42
+ begin
43
+ record = Resque.info
44
+ tag = @tag
45
+ if tag
46
+ Engine.emit(tag, Engine.now, record)
47
+ end
48
+ rescue => e
49
+ $log.error "exec failed to emit", :error=>$!.to_s, :line => e.message
50
+ $log.warn_backtrace $!.backtrace
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require 'fluent/test'
5
+
6
+ require File.dirname(__FILE__) + '/spec_helper'
7
+
8
+ DEFAULT_CONFIG = %[
9
+ tag test
10
+ host 127.0.0.1
11
+ port 6379
12
+ run_interval 1s
13
+ ]
14
+
15
+ describe Fluent::ResqueStatInput do
16
+ before { Fluent::Test.setup }
17
+ context 'test_emit' do
18
+ it do
19
+ d = Fluent::Test::InputTestDriver.new(Fluent::ResqueStatInput).configure(DEFAULT_CONFIG)
20
+ d.run do
21
+ sleep 2
22
+ end
23
+ emits = d.emits
24
+ emits.length.should > 0
25
+ emits[0][0].should eql('test')
26
+ emits[0][2].keys.should eql([:pending, :processed, :queues, :workers, :working, :failed, :servers, :environment])
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+
33
+
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ Bundler.setup(:default, :test)
6
+ Bundler.require(:default, :test)
7
+
8
+ require 'rspec'
9
+ require 'fluent/test'
10
+
11
+ $TESTING=true
12
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
13
+ require 'fluent/plugin/in_resque_stat'
14
+
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-resque_stat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Spring_MT
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: resque
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.22'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.22'
30
+ - !ruby/object:Gem::Dependency
31
+ name: fluentd
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! 'Fluent input plugin for Resque info
47
+
48
+ '
49
+ email:
50
+ - today.is.sky.blue.sky@gmail.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .travis.yml
57
+ - Gemfile
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - fluent-plugin-resque_stat.gemspec
62
+ - lib/fluent/plugin/in_resque_stat.rb
63
+ - spec/in_resque_stat_spec.rb
64
+ - spec/spec_helper.rb
65
+ homepage: https://github.com/SpringMT/fluent-plugin-resque_stat
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project: fluent-plugin-resque_stat
85
+ rubygems_version: 1.8.23
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Fluent input plugin for Resque info
89
+ test_files:
90
+ - spec/in_resque_stat_spec.rb
91
+ - spec/spec_helper.rb