fluent-plugin-munin 0.2.2 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -30,10 +30,12 @@ gem install fluent-plugin-munin
30
30
  # specify munin plugin names by comma separated values.
31
31
  service cpu # Optional (not specify, fetch all enabled munin metrics)
32
32
  # inserting hostname into record.
33
- record_hostname yes # Optional (yes/no)
34
- # multi row results to be nested or separated record.
35
- nest_result no # Optional (yes/no)
36
- nest_keyname data # Optional (default: result)
33
+ record_hostname yes # Optional (default: no)
34
+ # converting values type from string to number.
35
+ convert_type yes # Optional (default: no)
36
+ # metrics datasets to be nested or separated record.
37
+ nest_result no # Optional (default: no)
38
+ nest_key data # Optional (default: result)
37
39
  </source>
38
40
 
39
41
  <match input.munin.*>
@@ -52,16 +54,21 @@ record_hostname: yes, nest_result: no
52
54
  input.munin.cpu: {"hostname":"myhost.example.com","service":"cpu","user":"113183","nice":"340","system":"26584","idle":"74205345","iowait":"26134","irq":"1","softirq":"506","steal":"0","guest":"0"}
53
55
  `````
54
56
 
55
- record_hostname: yes, nest_result: yes
57
+ record_hostname: yes, nest_result: no, convert_type: yes #RECOMMEND
58
+ `````
59
+ input.munin.cpu: {"hostname":"myhost.example.com","service":"cpu","user":113183,"nice":340,"system":26584,"idle":74205345,"iowait":26134,"irq":1,"softirq":506,"steal":0,"guest":0}
60
+ `````
61
+
62
+ record_hostname: yes, nest_result: yes, nest_key: data
56
63
  `````
57
64
  input.munin.cpu: {"hostname":"myhost.example.com","service":"cpu","data":{"user":"113183","nice":"340","system":"26584","idle":"74205345","iowait":"26134","irq":"1","softirq":"506","steal":"0","guest":"0"}}
58
65
  `````
59
66
 
60
67
  ### MongoDB find example
61
- record_hostname: yes, nest_result: yes
68
+ record_hostname: yes, nest_result: yes, convert_type: yes
62
69
  `````
63
70
  > use munin
64
- > db.cpu.find({ "data.iowait" : { $gt : "200000" } })
71
+ > db.cpu.find({ "data.iowait" : { $gt : 200000 } })
65
72
  `````
66
73
 
67
74
  ## TODO
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-munin"
6
- s.version = "0.2.2"
6
+ s.version = "0.3.1"
7
7
  s.authors = ["Kentaro Yoshida"]
8
8
  s.email = ["y.ken.studio@gmail.com"]
9
9
  s.homepage = "https://github.com/y-ken/fluent-plugin-munin"
@@ -14,6 +14,7 @@ module Fluent
14
14
  config_param :service, :string, :default => 'all'
15
15
  config_param :nest_result, :string, :default => nil
16
16
  config_param :nest_key, :string, :default => 'result'
17
+ config_param :convert_type, :string, :default => 'no'
17
18
  config_param :record_hostname, :string, :default => nil
18
19
 
19
20
  def configure(conf)
@@ -22,8 +23,9 @@ module Fluent
22
23
  @interval = Config.time_value(@interval)
23
24
  service_list = get_service_list
24
25
  @services = @service == 'all' ? service_list : @service.split(',')
25
- @record_hostname = Config.bool_value(@record_hostname) || false
26
26
  @nest_result = Config.bool_value(@nest_result) || false
27
+ @convert_type = Config.bool_value(@convert_type) || false
28
+ @record_hostname = Config.bool_value(@record_hostname) || false
27
29
  $log.info "munin-node connected: #{@hostname} #{service_list}"
28
30
  $log.info "following munin-node service: #{@service}"
29
31
  end
@@ -90,11 +92,26 @@ module Fluent
90
92
  @munin ||= get_connection
91
93
  begin
92
94
  values = @munin.fetch(key)
95
+ return convert_type(values[key]) if @convert_type
93
96
  return values[key]
94
97
  rescue Munin::ConnectionError
95
98
  @munin = get_connection
96
99
  retry
97
100
  end
98
101
  end
102
+
103
+ def convert_type(ary)
104
+ data = Hash.new
105
+ ary.each do |key,value|
106
+ if value == value.to_f.to_s
107
+ data.store(key, value.to_f)
108
+ elsif value == value.to_i.to_s
109
+ data.store(key, value.to_i)
110
+ else
111
+ data.store(key, value)
112
+ end
113
+ end
114
+ return data
115
+ end
99
116
  end
100
117
  end
@@ -10,7 +10,8 @@ class MuninInputTest < Test::Unit::TestCase
10
10
  port 4949
11
11
  interval 30
12
12
  tag_prefix input.munin
13
- record_hostname yes
13
+ record_hostname yes
14
+ convert_type no
14
15
  ]
15
16
 
16
17
  def create_driver(conf=CONFIG,tag='test')
@@ -26,9 +27,10 @@ class MuninInputTest < Test::Unit::TestCase
26
27
  port 4949
27
28
  interval 30
28
29
  tag_prefix input.munin
29
- record_hostname yes
30
+ record_hostname yes
31
+ convert_type no
30
32
  ]
31
- d.instance.inspect
33
+ p d.instance.inspect
32
34
  assert_equal 'localhost', d.instance.host
33
35
  assert_equal 4949, d.instance.port
34
36
  assert_equal 30, d.instance.interval
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-munin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-13 00:00:00.000000000 Z
12
+ date: 2012-10-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
16
- requirement: &12769240 !ruby/object:Gem::Requirement
16
+ requirement: &15089900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *12769240
24
+ version_requirements: *15089900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fluentd
27
- requirement: &12767660 !ruby/object:Gem::Requirement
27
+ requirement: &15089460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *12767660
35
+ version_requirements: *15089460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: munin-ruby
38
- requirement: &12766880 !ruby/object:Gem::Requirement
38
+ requirement: &15089040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *12766880
46
+ version_requirements: *15089040
47
47
  description:
48
48
  email:
49
49
  - y.ken.studio@gmail.com