fluent-plugin-munin-node 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/fluent/plugin/in_munin_node.rb +37 -17
- data/lib/fluent_plugin_munin_node/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c9894aedd7f5e65474011a7c44cadeb75a97e5c
|
4
|
+
data.tar.gz: 763b74a60b945d4a8697cd5866acced390574e5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 806b3445ba8870f463f0f32ba02d73c53da0bda261d23a91f19fb1f6a763effe82742ed2f5060b8511de3900ddeae88ca88e49f73f1066b59c60792691a64006
|
7
|
+
data.tar.gz: bdc1efccffada695ab93397604400a7cf5a51f6b390978f770db6bbec5f5917935ae1653f42d49a181726c5139d40bcceaf8e9cffa5f65e853c11949dee2239a
|
data/README.md
CHANGED
@@ -11,16 +11,18 @@ class Fluent::MuninNodeInput < Fluent::Input
|
|
11
11
|
define_method('router') { Fluent::Engine }
|
12
12
|
end
|
13
13
|
|
14
|
-
config_param :node_host,
|
15
|
-
config_param :node_port,
|
16
|
-
config_param :interval,
|
17
|
-
config_param :tag_prefix,
|
18
|
-
config_param :bulk_suffix,
|
19
|
-
config_param :service_key,
|
20
|
-
config_param :field_key,
|
21
|
-
config_param :value_key,
|
22
|
-
config_param :extra,
|
23
|
-
config_param :bulk,
|
14
|
+
config_param :node_host, :string, :default => '127.0.0.1'
|
15
|
+
config_param :node_port, :integer, :default => 4949
|
16
|
+
config_param :interval, :time, :default => 60
|
17
|
+
config_param :tag_prefix, :string, :default => 'munin'
|
18
|
+
config_param :bulk_suffix, :string, :default => 'metrics'
|
19
|
+
config_param :service_key, :string, :default => 'service'
|
20
|
+
config_param :field_key, :string, :default => 'field'
|
21
|
+
config_param :value_key, :string, :default => 'value'
|
22
|
+
config_param :extra, :hash, :default => {}
|
23
|
+
config_param :bulk, :bool, :default => false
|
24
|
+
config_param :include_service, :string, :default => nil
|
25
|
+
config_param :exclude_service, :string, :default => nil
|
24
26
|
|
25
27
|
def initialize
|
26
28
|
super
|
@@ -29,6 +31,9 @@ class Fluent::MuninNodeInput < Fluent::Input
|
|
29
31
|
|
30
32
|
def configure(conf)
|
31
33
|
super
|
34
|
+
|
35
|
+
@include_service = Regexp.new(@include_service) if @include_service
|
36
|
+
@exclude_service = Regexp.new(@exclude_service) if @exclude_service
|
32
37
|
end
|
33
38
|
|
34
39
|
def start
|
@@ -44,7 +49,7 @@ class Fluent::MuninNodeInput < Fluent::Input
|
|
44
49
|
@loop.watchers.each(&:detach)
|
45
50
|
@loop.stop
|
46
51
|
|
47
|
-
# XXX: Comment out for exit
|
52
|
+
# XXX: Comment out for exit quickly. Is it OK?
|
48
53
|
#@thread.join
|
49
54
|
end
|
50
55
|
|
@@ -60,10 +65,11 @@ class Fluent::MuninNodeInput < Fluent::Input
|
|
60
65
|
def fetch_items
|
61
66
|
values_by_service = {}
|
62
67
|
|
63
|
-
# It
|
68
|
+
# It connect to Munin node every time.
|
64
69
|
node = Munin::Node.new(@node_host, @node_port)
|
70
|
+
services = filter_service(node.list)
|
65
71
|
|
66
|
-
|
72
|
+
services.each do |service|
|
67
73
|
begin
|
68
74
|
service_values = node.fetch(service)
|
69
75
|
values_by_service.update(service_values)
|
@@ -77,11 +83,9 @@ class Fluent::MuninNodeInput < Fluent::Input
|
|
77
83
|
end
|
78
84
|
|
79
85
|
def emit_items(values_by_service)
|
80
|
-
time = Time.now
|
81
|
-
|
82
86
|
if @bulk
|
83
87
|
tag = @tag_prefix + '.' + @bulk_suffix
|
84
|
-
router.emit(tag,
|
88
|
+
router.emit(tag, Fluent::Engine.now, values_by_service.merge(extra))
|
85
89
|
else
|
86
90
|
values_by_service.each do |service, value_by_field|
|
87
91
|
value_by_field.each do |fieldname, value|
|
@@ -93,12 +97,28 @@ class Fluent::MuninNodeInput < Fluent::Input
|
|
93
97
|
@value_key => value =~ /\./ ? value.to_f : value.to_i,
|
94
98
|
}
|
95
99
|
|
96
|
-
router.emit(tag,
|
100
|
+
router.emit(tag, Fluent::Engine.now, record.merge(extra))
|
97
101
|
end
|
98
102
|
end
|
99
103
|
end
|
100
104
|
end
|
101
105
|
|
106
|
+
def filter_service(services)
|
107
|
+
if @exclude_service
|
108
|
+
services = services.reject do |srvc|
|
109
|
+
srvc =~ @exclude_service
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
if @include_service
|
114
|
+
services = services.select do |srvc|
|
115
|
+
srvc =~ @include_service
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
services
|
120
|
+
end
|
121
|
+
|
102
122
|
class TimerWatcher < Coolio::TimerWatcher
|
103
123
|
def initialize(interval, repeat, log, &callback)
|
104
124
|
@callback = callback
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-munin-node
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|