fluent-plugin-munin-node 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -6
- data/lib/fluent/plugin/in_munin_node.rb +17 -13
- data/lib/fluent_plugin_munin_node/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b2f43a0abffec39896ac67cc928983f906c1efa
|
4
|
+
data.tar.gz: 5341b9a712d6666a328196eed80997ee44d059cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d91d6b699ee07ac0588a277444b003ab94c9c00137f5f17265342d13d35364966bf317889b461ea01db4e40d7a1c30d5733290988269764cc623434c5e63430c
|
7
|
+
data.tar.gz: b057cf26faf1dd9e57c34dcaeef3bbe5c1dfad05ce6835560d70e858e5947089c9c43135379025f1e9af09458fd81b43ee2be15d2e3dd25b494699b70af648a7
|
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
Fluentd input plugin for Munin node.
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-munin-node.svg)](http://badge.fury.io/rb/fluent-plugin-munin-node)
|
6
|
+
[![Build Status](https://travis-ci.org/winebarrel/fluent-plugin-munin-node.svg)](https://travis-ci.org/winebarrel/fluent-plugin-munin-node)
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
@@ -27,8 +30,9 @@ Or install it yourself as:
|
|
27
30
|
#node_host 127.0.0.1
|
28
31
|
#node_port 10050
|
29
32
|
#interval 60
|
30
|
-
#
|
31
|
-
#
|
33
|
+
#tag_prefix munin
|
34
|
+
#bulk_suffix metrics
|
35
|
+
#service_key service
|
32
36
|
#field_key field
|
33
37
|
#value_key value
|
34
38
|
#extra {}
|
@@ -48,9 +52,9 @@ Or install it yourself as:
|
|
48
52
|
```
|
49
53
|
|
50
54
|
```
|
51
|
-
2015-91-02 12:30:09 +0000 munin.
|
52
|
-
2015-91-02 12:30:09 +0000 munin.
|
53
|
-
2015-91-02 12:30:09 +0000 munin.
|
55
|
+
2015-91-02 12:30:09 +0000 munin.cpu.user: {"service":"cpu","field":"user","value":"4192","hostname":"my-host"}
|
56
|
+
2015-91-02 12:30:09 +0000 munin.cpu.nice: {"service":"cpu","field":"nice","value":"0","hostname":"my-host"}
|
57
|
+
2015-91-02 12:30:09 +0000 munin.cpu.system: {"service":"cpu","field":"system","value":"1935","hostname":"my-host"}
|
54
58
|
```
|
55
59
|
|
56
60
|
## Get munin data as a single record
|
@@ -64,5 +68,5 @@ Or install it yourself as:
|
|
64
68
|
```
|
65
69
|
|
66
70
|
```
|
67
|
-
2015-01-02 12:30:40 +0000 munin.
|
71
|
+
2015-01-02 12:30:40 +0000 munin.metrics: {"cpu":{"user":"4112","nice":"0","system":"1894",...,"hostname":"my-host"}
|
68
72
|
```
|
@@ -14,8 +14,9 @@ class Fluent::MuninNodeInput < Fluent::Input
|
|
14
14
|
config_param :node_host, :string, :default => '127.0.0.1'
|
15
15
|
config_param :node_port, :integer, :default => 4949
|
16
16
|
config_param :interval, :time, :default => 60
|
17
|
-
config_param :
|
18
|
-
config_param :
|
17
|
+
config_param :tag_prefix, :string, :default => 'munin'
|
18
|
+
config_param :bulk_suffix, :string, :default => 'metrics'
|
19
|
+
config_param :service_key, :string, :default => 'service'
|
19
20
|
config_param :field_key, :string, :default => 'field'
|
20
21
|
config_param :value_key, :string, :default => 'value'
|
21
22
|
config_param :extra, :hash, :default => {}
|
@@ -57,39 +58,42 @@ class Fluent::MuninNodeInput < Fluent::Input
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def fetch_items
|
60
|
-
|
61
|
+
values_by_service = {}
|
61
62
|
|
62
63
|
# It's connected every fetch of metrics.
|
63
64
|
node = Munin::Node.new(@node_host, @node_port)
|
64
65
|
|
65
|
-
node.list.each do |
|
66
|
+
node.list.each do |service|
|
66
67
|
begin
|
67
|
-
|
68
|
-
|
68
|
+
service_values = node.fetch(service)
|
69
|
+
values_by_service.update(service_values)
|
69
70
|
rescue => e
|
70
|
-
log.warn("#{
|
71
|
+
log.warn("#{service}: #{e.message}")
|
71
72
|
log.warn_backtrace(e.backtrace)
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
emit_items(
|
76
|
+
emit_items(values_by_service)
|
76
77
|
end
|
77
78
|
|
78
|
-
def emit_items(
|
79
|
+
def emit_items(values_by_service)
|
79
80
|
time = Time.now
|
80
81
|
|
81
82
|
if @bulk
|
82
|
-
|
83
|
+
tag = @tag_prefix + '.' + @bulk_suffix
|
84
|
+
router.emit(tag, time.to_i, values_by_service.merge(extra))
|
83
85
|
else
|
84
|
-
|
86
|
+
values_by_service.each do |service, value_by_field|
|
85
87
|
value_by_field.each do |fieldname, value|
|
88
|
+
tag = [@tag_prefix, service, fieldname].join('.')
|
89
|
+
|
86
90
|
record = {
|
87
|
-
@
|
91
|
+
@service_key => service,
|
88
92
|
@field_key => fieldname,
|
89
93
|
@value_key => value =~ /\./ ? value.to_f : value.to_i,
|
90
94
|
}
|
91
95
|
|
92
|
-
router.emit(
|
96
|
+
router.emit(tag, time.to_i, record.merge(extra))
|
93
97
|
end
|
94
98
|
end
|
95
99
|
end
|