fluent-plugin-chef-client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE +14 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/fluent-plugin-chef-client.gemspec +25 -0
- data/lib/fluent/plugin/in_chef_client.rb +63 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c88513a6f0f6fc5ce4aa8be22caf3e3bec0fb8b2
|
4
|
+
data.tar.gz: ab028022a87e013d5d146c2c2cb3ed4e73568f2a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d7870177e02730ecabdcb25330e289975f7a2641049af3aa210145432910064b559524df4064c31eaa0d6863227459be7631a4ee35eb942b29ba71fbc5af4745
|
7
|
+
data.tar.gz: cc7807486939dd23caffe9d0a7401077ec02326fbbe1e31e1ba435510bfd77ee2e9fef16cf8aba9382d86267d05d211a54845dd3db7db1a18348e8d7008c5d1c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (C) 2015 Yamashita, Yuu
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# fluent-plugin-chef-client
|
2
|
+
|
3
|
+
A fluent plugin implementation to fetch information of chef-client running on the host.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fluent-plugin-chef-client'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fluent-plugin-chef-client
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/[my-github-username]/fluent-plugin-chef-client/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: 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 |spec|
|
6
|
+
spec.name = "fluent-plugin-chef-client"
|
7
|
+
spec.version = "0.1.0"
|
8
|
+
spec.authors = ["Yamashita Yuu"]
|
9
|
+
spec.email = ["peek824545201@gmail.com"]
|
10
|
+
spec.license = "Apache-2.0"
|
11
|
+
|
12
|
+
spec.summary = %q{a fluent plugin for chef-client}
|
13
|
+
spec.description = %q{a fluent plugin for chef-client.}
|
14
|
+
spec.homepage = "https://github.com/yyuu/fluent-plugin-chef-client"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_dependency "chef", ">= 11.18.0"
|
24
|
+
spec.add_dependency "fluentd", ">= 0.10.55"
|
25
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Fluent
|
2
|
+
class ChefClientInput < Input
|
3
|
+
Plugin.register_input("chef_client", self)
|
4
|
+
|
5
|
+
config_param :check_interval, :integer, :default => 60
|
6
|
+
config_param :chef_server_url, :string, :default => nil
|
7
|
+
config_param :client_key, :string, :default => nil
|
8
|
+
config_param :config_file, :string, :default => "/etc/chef/config.rb"
|
9
|
+
config_param :node_name, :string, :default => nil
|
10
|
+
config_param :tag_prefix, :string, :default => "chef_client"
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
require "chef"
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure(conf)
|
18
|
+
super
|
19
|
+
::Chef::Config.from_file(@config_file)
|
20
|
+
if @chef_server_url
|
21
|
+
::Chef::Config[:chef_server_url] = @chef_server_url
|
22
|
+
end
|
23
|
+
if @client_key
|
24
|
+
::Chef::Config[:client_key] = @client_key
|
25
|
+
end
|
26
|
+
if @node_name
|
27
|
+
::Chef::Config[:node_name] = @node_name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def start
|
32
|
+
@running = true
|
33
|
+
@thread = ::Thread.new(&method(:run))
|
34
|
+
end
|
35
|
+
|
36
|
+
def shutdown
|
37
|
+
@running = false
|
38
|
+
@thread.join
|
39
|
+
end
|
40
|
+
|
41
|
+
def run
|
42
|
+
node_name = ::Chef::Config[:node_name]
|
43
|
+
next_run = ::Time.new
|
44
|
+
while @running
|
45
|
+
if ::Time.new < next_run
|
46
|
+
sleep(1)
|
47
|
+
else
|
48
|
+
begin
|
49
|
+
now = Engine.now
|
50
|
+
node = ::Chef::Node.load(node_name)
|
51
|
+
ohai_time = node["ohai_time"]
|
52
|
+
Engine.emit("#{@tag_prefix}.behind_from", now, {"value" => ohai_time ? (now - ohai_time) : -1})
|
53
|
+
rescue => error
|
54
|
+
$log.warn("failed to load attributes of node \`#{node_name.inspect}': #{error.inspect}")
|
55
|
+
next
|
56
|
+
ensure
|
57
|
+
next_run = ::Time.new + @check_interval
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-chef-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yamashita Yuu
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: chef
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 11.18.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 11.18.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fluentd
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.10.55
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.55
|
69
|
+
description: a fluent plugin for chef-client.
|
70
|
+
email:
|
71
|
+
- peek824545201@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- fluent-plugin-chef-client.gemspec
|
82
|
+
- lib/fluent/plugin/in_chef_client.rb
|
83
|
+
homepage: https://github.com/yyuu/fluent-plugin-chef-client
|
84
|
+
licenses:
|
85
|
+
- Apache-2.0
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.2.3
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: a fluent plugin for chef-client
|
107
|
+
test_files: []
|