fluent-plugin-specinfra_inventory 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e40de8d848e26a71a26c212ed59acb2859137db3
4
+ data.tar.gz: 2d0e70c4e86e30311a606f38fd3e40374c84df82
5
+ SHA512:
6
+ metadata.gz: 8b4287f1e14a392579eed53bed1d01e2255a0472bcf928b8a1f9c83fbdd4337d2e5b206778fe45409b46aacdf246378d4d50414cca081fa96cd842bf1fe91ed4
7
+ data.tar.gz: 782dae04b88ee21be1a72b401ef081697026eafb7afa0e2fc0357d6b8b5c527b16627329307f2b3242aae8ceb3963c04dace48448e842f66ef488d75a618eed3
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ /vendor
16
+ /*.conf
17
+ /*.log.*
18
+ /Vagrantfile
19
+ /.vagrant
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.1
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - ruby-head
8
+
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-specinfra_inventory.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Masashi Terui
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,101 @@
1
+ # fluent-plugin-specinfra_inventory
2
+
3
+ Specinfra Host Inventory Plugin for [Fluentd](http://github.com/fluent/fluentd)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fluent-plugin-specinfra_inventory'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fluent-plugin-specinfra_inventory
20
+
21
+ ## Configuration
22
+
23
+ ```
24
+ <source>
25
+ time_span 300
26
+ tag_prefix example.prefix
27
+ backend exec
28
+ inventory_keys ["cpu","memory"]
29
+ family ubuntu
30
+ release 14.04
31
+ arch x86_64
32
+ path /user/local/bin
33
+ host localhost
34
+ ssh_user vagrant
35
+ ssh_port 2222
36
+ env {"LANG": "C"}
37
+ </source>
38
+ ```
39
+
40
+ ### time_span
41
+ Time span(sec) for collecting inventory.
42
+ defualt: `60`
43
+
44
+ ### tag_prefix
45
+ Prefix of tags of events.
46
+ Event tags are added together inventory key at the end. like: `example.prefix.cpu`
47
+ default: `specinfra.inventory`
48
+
49
+ ### backend
50
+ Specinfra backend type
51
+ default: `exec`
52
+
53
+
54
+ ### inventory_keys
55
+ Key of Host Inventory
56
+
57
+ ### family, release, arch
58
+ See [Multi OS Support](http://serverspec.org/tutorial.html)
59
+
60
+ ### path
61
+ `PATH` environment variable
62
+
63
+ ### host
64
+ Target host
65
+
66
+ ### ssh_user
67
+ SSH user name
68
+
69
+ ### ssh_port
70
+ SSH port
71
+
72
+ ### env
73
+ Environment variables
74
+
75
+ ## Contributing
76
+
77
+ * Source hosted at [GitHub][repo]
78
+ * Report issues/questions/feature requests on [GitHub Issues][issues]
79
+
80
+ Pull requests are very welcome! Make sure your patches are well tested.
81
+ Ideally create a topic branch for every separate change you make. For
82
+ example:
83
+
84
+ 1. Fork the repo
85
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
86
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
87
+ 4. Push to the branch (`git push origin my-new-feature`)
88
+ 5. Create new Pull Request
89
+
90
+ ## Authors
91
+
92
+ Created and maintained by [Masashi Terui][author] (<marcy9114@gmail.com>)
93
+
94
+ ## License
95
+
96
+ MIT (see [LICENSE][license])
97
+
98
+ [author]: https://github.com/marcy-terui
99
+ [issues]: https://github.com/marcy-terui/fluent-plugin-specinfra_inventory/issues
100
+ [license]: https://github.com/marcy-terui/fluent-plugin-specinfra_inventory/blob/master/LICENSE.txt
101
+ [repo]: https://github.com/marcy-terui/fluent-plugin-specinfra_inventory
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = 'spec/*_spec.rb'
7
+ end
8
+
9
+ task :default => [:spec]
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fluent/plugin/specinfra_inventory/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fluent-plugin-specinfra_inventory"
8
+ spec.version = Fluent::Plugin::SpecinfraInventory::VERSION
9
+ spec.authors = ["Masashi Terui"]
10
+ spec.email = ["marcy9114@gmail.com"]
11
+ spec.summary = %q{Specinfra Host Inventory Plugin for Fluentd}
12
+ spec.description = %q{Specinfra Host Inventory Plugin for Fluentd}
13
+ spec.homepage = "https://github.com/marcy-terui/fluent-plugin-specinfra_inventory"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "fluentd"
22
+ spec.add_dependency "specinfra"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "coveralls"
28
+ end
@@ -0,0 +1,75 @@
1
+ module Fluent
2
+ class SpecinfraInventoryInput < Input
3
+ Plugin.register_input('specinfra_inventory', self)
4
+
5
+ config_param :time_span, :integer, default: 60
6
+ config_param :tag_prefix, :string, default: 'specinfra.inventory'
7
+ config_param :backend, :string, default: 'exec'
8
+ config_param :family, :string, default: nil
9
+ config_param :release, :string, default: nil
10
+ config_param :arch, :string, default: nil
11
+ config_param :path, :string, default: nil
12
+ config_param :host, :string, default: nil
13
+ config_param :ssh_user, :string, default: nil
14
+ config_param :ssh_port, :integer, default: nil
15
+ config_param :env, :hash, default: {}
16
+ config_param :inventory_keys, :array
17
+
18
+ def initialize
19
+ super
20
+ require 'specinfra'
21
+ require 'specinfra/host_inventory'
22
+ end
23
+
24
+ def configure(conf)
25
+ super
26
+
27
+ Specinfra.configuration.send(:backend, @backend.to_sym)
28
+ Specinfra.configuration.send(:path, @path) if @path
29
+ Specinfra.configuration.send(:host, @host) if @host
30
+ Specinfra.configuration.send(:env, @env) if @env
31
+
32
+ opt = {}
33
+ opt[:family] = @family if @family
34
+ opt[:release] = @release if @release
35
+ opt[:arch] = @arch if @arch
36
+ Specinfra.configuration.send(:os, opt) if opt.length > 0
37
+
38
+ opt = {}
39
+ opt[:user] = @ssh_user if @ssh_user
40
+ opt[:port] = @ssh_port if @ssh_port
41
+ Specinfra.configuration.send(:ssh_options, opt) if opt.length > 0
42
+
43
+ @inventory = Specinfra::HostInventory.instance
44
+ end
45
+
46
+ def start
47
+ @finished = false
48
+ @thread = Thread.new(&method(:run))
49
+ end
50
+
51
+ def shutdown
52
+ @finished = true
53
+ @thread.join
54
+ end
55
+
56
+ def run
57
+ loop do
58
+ time = Engine.now
59
+ @inventory_keys.each do |key|
60
+ Engine.emit(tag(key), time, record(key))
61
+ end
62
+ sleep @timespan
63
+ end
64
+ end
65
+
66
+ def tag(key)
67
+ "#{@tag_prefix}.#{key}"
68
+ end
69
+
70
+ def record(key)
71
+ @inventory[key]
72
+ end
73
+
74
+ end
75
+ end
@@ -0,0 +1,9 @@
1
+ require "fluent/plugin/specinfra_inventory/version"
2
+
3
+ module Fluent
4
+ module Plugin
5
+ module SpecinfraInventory
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Fluent
2
+ module Plugin
3
+ module SpecinfraInventory
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+ require 'fluent/plugin/in_specinfra_inventory'
3
+
4
+ describe Fluent::SpecinfraInventoryInput do
5
+ before do
6
+ Fluent::Test.setup
7
+ @d = Fluent::Test::InputTestDriver.new(Fluent::SpecinfraInventoryInput).configure(config)
8
+ end
9
+
10
+ let(:config) do
11
+ %[
12
+ time_span 300
13
+ tag_prefix test.prefix
14
+ backend exec
15
+ inventory_keys ["cpu"]
16
+ family ubuntu
17
+ release 14.04
18
+ arch x86_64
19
+ path /path/test
20
+ host localhost
21
+ ssh_user test-user
22
+ ssh_port 2222
23
+ env {"TEST_ENV": "test_value"}
24
+ ]
25
+ end
26
+
27
+ describe "config" do
28
+ example { expect(@d.instance.time_span).to eq 300 }
29
+ example { expect(@d.instance.tag_prefix).to eq "test.prefix" }
30
+ example { expect(@d.instance.backend).to eq "exec" }
31
+ example { expect(@d.instance.inventory_keys).to eq ["cpu"] }
32
+ example { expect(@d.instance.family).to eq "ubuntu" }
33
+ example { expect(@d.instance.release).to eq "14.04" }
34
+ example { expect(@d.instance.arch).to eq "x86_64" }
35
+ example { expect(@d.instance.path).to eq "/path/test" }
36
+ example { expect(@d.instance.host).to eq "localhost" }
37
+ example { expect(@d.instance.ssh_user).to eq "test-user" }
38
+ example { expect(@d.instance.ssh_port).to eq 2222 }
39
+ example { expect(@d.instance.env).to include('TEST_ENV' => 'test_value') }
40
+ end
41
+
42
+ describe "tag" do
43
+ example { expect(@d.instance.tag("cpu")).to eq "test.prefix.cpu" }
44
+ end
45
+
46
+ describe "record" do
47
+ example { expect(@d.instance.record("cpu")).to have_key "total" }
48
+ end
49
+ end
@@ -0,0 +1,81 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'fluent/load'
5
+ require 'fluent/test'
6
+
7
+ require 'fluent/plugin/in_specinfra_inventory'
8
+
9
+ RSpec.configure do |config|
10
+ # rspec-expectations config goes here. You can use an alternate
11
+ # assertion/expectation library such as wrong or the stdlib/minitest
12
+ # assertions if you prefer.
13
+ config.expect_with :rspec do |expectations|
14
+ # This option will default to `true` in RSpec 4. It makes the `description`
15
+ # and `failure_message` of custom matchers include text for helper methods
16
+ # defined using `chain`, e.g.:
17
+ # be_bigger_than(2).and_smaller_than(4).description
18
+ # # => "be bigger than 2 and smaller than 4"
19
+ # ...rather than:
20
+ # # => "be bigger than 2"
21
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
22
+ end
23
+
24
+ # rspec-mocks config goes here. You can use an alternate test double
25
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
26
+ config.mock_with :rspec do |mocks|
27
+ # Prevents you from mocking or stubbing a method that does not exist on
28
+ # a real object. This is generally recommended, and will default to
29
+ # `true` in RSpec 4.
30
+ mocks.verify_partial_doubles = true
31
+ end
32
+
33
+ # The settings below are suggested to provide a good initial experience
34
+ # with RSpec, but feel free to customize to your heart's content.
35
+ =begin
36
+ # These two settings work together to allow you to limit a spec run
37
+ # to individual examples or groups you care about by tagging them with
38
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
39
+ # get run.
40
+ config.filter_run :focus
41
+ config.run_all_when_everything_filtered = true
42
+
43
+ # Limits the available syntax to the non-monkey patched syntax that is
44
+ # recommended. For more details, see:
45
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
46
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
47
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
48
+ config.disable_monkey_patching!
49
+
50
+ # This setting enables warnings. It's recommended, but in some cases may
51
+ # be too noisy due to issues in dependencies.
52
+ config.warnings = true
53
+
54
+ # Many RSpec users commonly either run the entire suite or an individual
55
+ # file, and it's useful to allow more verbose output when running an
56
+ # individual spec file.
57
+ if config.files_to_run.one?
58
+ # Use the documentation formatter for detailed output,
59
+ # unless a formatter has already been configured
60
+ # (e.g. via a command-line flag).
61
+ config.default_formatter = 'doc'
62
+ end
63
+
64
+ # Print the 10 slowest examples and example groups at the
65
+ # end of the spec run, to help surface which specs are running
66
+ # particularly slow.
67
+ config.profile_examples = 10
68
+
69
+ # Run specs in random order to surface order dependencies. If you find an
70
+ # order dependency and want to debug it, you can fix the order by providing
71
+ # the seed, which is printed after each run.
72
+ # --seed 1234
73
+ config.order = :random
74
+
75
+ # Seed global randomization in this process using the `--seed` CLI option.
76
+ # Setting this allows you to use `--seed` to deterministically reproduce
77
+ # test failures related to randomization by passing the same `--seed` value
78
+ # as the one that triggered the failure.
79
+ Kernel.srand config.seed
80
+ =end
81
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-specinfra_inventory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Masashi Terui
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: specinfra
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Specinfra Host Inventory Plugin for Fluentd
98
+ email:
99
+ - marcy9114@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - fluent-plugin-specinfra_inventory.gemspec
112
+ - lib/fluent/plugin/in_specinfra_inventory.rb
113
+ - lib/fluent/plugin/specinfra_inventory.rb
114
+ - lib/fluent/plugin/specinfra_inventory/version.rb
115
+ - spec/in_specinfra_inventory_spec.rb
116
+ - spec/spec_helper.rb
117
+ homepage: https://github.com/marcy-terui/fluent-plugin-specinfra_inventory
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.2.2
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Specinfra Host Inventory Plugin for Fluentd
141
+ test_files:
142
+ - spec/in_specinfra_inventory_spec.rb
143
+ - spec/spec_helper.rb