fluent-plugin-chef-api 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/fluent-plugin-chef-api.gemspec +1 -1
- data/lib/fluent/plugin/in_chef_api.rb +27 -16
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15ef7ceb2205ce2e0669ab45ebcd0271db42d9d7
|
4
|
+
data.tar.gz: 392ab1da22f56d0b2b5b49928568a1ce3b997490
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2a389686b0cca8d1d393cf17969607b07247d9a2c6de76d8252a803b2c588eeaf59fdaf34057627a6a27e6abf7baf527e1bdec1ce77dd2d992c6d615f221f70
|
7
|
+
data.tar.gz: f3fa4382f1fd36c2ca39c596eee76ee45032791d63fdc8759a3c6d84af88230c4652e4575f9d797b7a1a8505665570e8e26302b1fafc3e9e054173178bd5b1f9
|
data/.gitignore
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-chef-api"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.5.0"
|
8
8
|
spec.authors = ["Yamashita Yuu"]
|
9
9
|
spec.email = ["peek824545201@gmail.com"]
|
10
10
|
spec.license = "Apache-2.0"
|
@@ -11,7 +11,8 @@ module Fluent
|
|
11
11
|
config_param :node_name, :string, :default => nil
|
12
12
|
config_param :tag, :string, :default => "chef_api"
|
13
13
|
config_param :chef_environment, :string, :default => nil
|
14
|
-
config_param :default_values, :hash, :default =>
|
14
|
+
config_param :default_values, :hash, :default => {}
|
15
|
+
config_param :monitor_multi, :bool, :default => true
|
15
16
|
|
16
17
|
def initialize
|
17
18
|
super
|
@@ -84,7 +85,11 @@ module Fluent
|
|
84
85
|
sleep(1)
|
85
86
|
else
|
86
87
|
begin
|
87
|
-
|
88
|
+
if @monitor_multi
|
89
|
+
run_once(connection)
|
90
|
+
else
|
91
|
+
run_once_single(connnection)
|
92
|
+
end
|
88
93
|
rescue => error
|
89
94
|
$log.warn("failed to fetch metrics: #{error.class}: #{error.message}")
|
90
95
|
next
|
@@ -95,12 +100,14 @@ module Fluent
|
|
95
100
|
end
|
96
101
|
end
|
97
102
|
|
103
|
+
def run_once_single(connection)
|
104
|
+
data = @default_values.dup
|
105
|
+
node = connection.nodes.fetch(@node_name)
|
106
|
+
emit_node_metrics(node, data)
|
107
|
+
end
|
108
|
+
|
98
109
|
def run_once(connection)
|
99
|
-
|
100
|
-
data = @default_values.dup
|
101
|
-
else
|
102
|
-
data = {}
|
103
|
-
end
|
110
|
+
data = @default_values.dup
|
104
111
|
if @chef_environment
|
105
112
|
nodes = connection.environments.fetch(@chef_environment).nodes
|
106
113
|
else
|
@@ -117,16 +124,20 @@ module Fluent
|
|
117
124
|
$log.warn("failed to shuffle nodes: #{error.class}: #{error.message}")
|
118
125
|
end
|
119
126
|
nodes.each do |node|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
127
|
+
emit_node_metrics(node, data)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def emit_node_metrics(node, data)
|
132
|
+
begin
|
133
|
+
Engine.emit("#{@tag}.run_list", Engine.now, data.merge({"value" => node.run_list.length, "node" => node.name}))
|
134
|
+
if node.automatic["ohai_time"]
|
135
|
+
ohai_time = node.automatic["ohai_time"].to_i
|
136
|
+
Engine.emit("#{@tag}.ohai_time", Engine.now, data.merge({"value" => ohai_time, "node" => node.name}))
|
137
|
+
Engine.emit("#{@tag}.behind_seconds", Engine.now, data.merge({"value" => Time.new.to_i - ohai_time, "node" => node.name}))
|
129
138
|
end
|
139
|
+
rescue => error
|
140
|
+
$log.warn("failed to fetch metrics from node: #{node.name}: #{error.class}: #{error.message}")
|
130
141
|
end
|
131
142
|
end
|
132
143
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-chef-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.6.
|
103
|
+
rubygems_version: 2.6.11
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: A fluentd plugin for Chef's API
|