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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6087ee8061854b22255421f654d36de1ed80fd30
4
- data.tar.gz: fc23f34555d9e601627237eb423ff7f18fcbbe8e
3
+ metadata.gz: 3b2f43a0abffec39896ac67cc928983f906c1efa
4
+ data.tar.gz: 5341b9a712d6666a328196eed80997ee44d059cf
5
5
  SHA512:
6
- metadata.gz: b00cbae7a9804bf5228b34a363bbf6c02b68703af031f67e1a3f9e7e254ce50a9000efc352f9c1213a1d9d275b18bd983f143c8af8831a49c6fb4b49a3a70b5f
7
- data.tar.gz: 5d8ed63d49e259a027cdb92eea18d4316c4ab46a3f6039b77c2b0bb5c0f467748241d6f2479fc635ef18602790017e1d98261085e9ecb2bdf9c6c572efec3003
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
- #tag munin.item
31
- #plugin_key plugin
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.item: {"plugin":"cpu","field":"user","value":"4192","hostname":"my-host"}
52
- 2015-91-02 12:30:09 +0000 munin.item: {"plugin":"cpu","field":"nice","value":"0","hostname":"my-host"}
53
- 2015-91-02 12:30:09 +0000 munin.item: {"plugin":"cpu","field":"system","value":"1935","hostname":"my-host"}
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.item: {"cpu":{"user":"4112","nice":"0","system":"1894",...,"hostname":"my-host"}
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 :tag, :string, :default => 'munin.item'
18
- config_param :plugin_key, :string, :default => 'plugin'
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
- values_by_plugin = {}
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 |plugin|
66
+ node.list.each do |service|
66
67
  begin
67
- plugin_values = node.fetch(plugin)
68
- values_by_plugin.update(plugin_values)
68
+ service_values = node.fetch(service)
69
+ values_by_service.update(service_values)
69
70
  rescue => e
70
- log.warn("#{plugin}: #{e.message}")
71
+ log.warn("#{service}: #{e.message}")
71
72
  log.warn_backtrace(e.backtrace)
72
73
  end
73
74
  end
74
75
 
75
- emit_items(values_by_plugin)
76
+ emit_items(values_by_service)
76
77
  end
77
78
 
78
- def emit_items(values_by_plugin)
79
+ def emit_items(values_by_service)
79
80
  time = Time.now
80
81
 
81
82
  if @bulk
82
- router.emit(@tag, time.to_i, values_by_plugin.merge(extra))
83
+ tag = @tag_prefix + '.' + @bulk_suffix
84
+ router.emit(tag, time.to_i, values_by_service.merge(extra))
83
85
  else
84
- values_by_plugin.each do |plugin, value_by_field|
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
- @plugin_key => plugin,
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(@tag, time.to_i, record.merge(extra))
96
+ router.emit(tag, time.to_i, record.merge(extra))
93
97
  end
94
98
  end
95
99
  end
@@ -1,3 +1,3 @@
1
1
  module FluentPluginMuninNode
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-munin-node
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara