fluent-plugin-nostat 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df5b9f59e4c9da71926005bb407a454dfed765aa
4
- data.tar.gz: 6b8eb04336f8c98eadc0cd122bdd12012c85f892
3
+ metadata.gz: 90b76a3a63ad5b11308798732e0d9478ec4f5901
4
+ data.tar.gz: c4af4b9b7d642605cb4878ed627dae32211a85c8
5
5
  SHA512:
6
- metadata.gz: 1df4acbbf2182feb1bd65fb73212f9b5a02ea835014887c05745c4f883c8adaaf60010231d80f8640dc23344e42a7b7c88993f11fc455b7b934e9706bb05e0d4
7
- data.tar.gz: 97b3299e5ed3a503212c02e02415675a3ea03f8a1aa9de7941be095717bf2d8556826c38dc769a3d8079cb8e1a7c0442de203d7f69ee9a6e8a8ebcb5df2fd5fb
6
+ metadata.gz: 3d60fe29f11d1ecb8dfaa4d3016553ea33f5c4f5843ff8dc3f531142f167d5d9b9b75cad76e6b0c1387eb5042e284f082a05852e0b3bb3b7a9f169951345c7a5
7
+ data.tar.gz: 00acffadc1a169db0364548e4958c27f19de0536e81c6c3f3452147ef3c66454f1e9f05318a6830b62838bb6cc209a880a931bad4bf405b7bcf3ee3e72c3f938
data/README.md CHANGED
@@ -15,11 +15,14 @@ $ gem install fluent-plugin-nostat
15
15
  type nostat
16
16
  run_interval 1
17
17
  mode dstat # raw or dstat
18
+ output_type graphite # hash or graphite
18
19
  </source>
19
20
  ```
20
- * tag : If there is no tag, the tag will be "{tag_prefix}.{hostname}.nostat".
21
+ * tag : If there is no tag value, the tag will be "{tag_prefix}.{hostname}.nostat".
21
22
  * run_interval : seconds
22
23
  * **mode** : raw or dstat. **raw** : just get the values from /proc/{STATS}. **dstat** : modify the values as dstat.
24
+ * **output_type** : hash or graphite. **hash** : old version style. **graphite** : slice all output for grapite.
25
+ * tag_prefix : If there is no tag value, the tag will be "{tag_prefix}.{hostname}.nostat".
23
26
 
24
27
  ## output
25
28
  ### raw mode
@@ -42,5 +45,46 @@ cpu={"usr"=>52773, "sys"=>28330, "idl"=>2217987, "wai"=>1995, "siq"=>4112, "hiq"
42
45
  cpu={"usr"=>0, "sys"=>0, "idl"=>100, "wai"=>0, "siq"=>0, "hiq"=>0} mem={"free"=>1693290496, "buff"=>0, "cach"=>60887040, "used"=>175230976} disk={"sda"=>{"read"=>0, "write"=>0}} net={"enp0s3"=>{"recv"=>344, "send"=>1668}, "enp0s8"=>{"recv"=>344, "send"=>1668}}
43
46
  ```
44
47
 
48
+ ### graphite output style
49
+ * full configuration example
50
+ ```
51
+ <source>
52
+ type nostat
53
+ tag_prefix graphite.
54
+ run_interval 60
55
+ mode dstat
56
+ output_type graphite
57
+ </source>
58
+
59
+ <match graphite.**>
60
+ type graphite
61
+ host 192.168.56.91
62
+ port 2003
63
+ tag_for prefix
64
+ remove_tag_prefix graphite
65
+ name_key_pattern ^*$
66
+ </match>
67
+
68
+ ```
69
+
70
+ * output
71
+ ```
72
+ tag : record
73
+ hostname.nostat.cpu : usr => 10
74
+ hostname.nostat.cpu : sys => 0
75
+ hostname.nostat.cpu : idl => 90
76
+ hostname.nostat.cpu : wai => 0
77
+
78
+ ...
79
+
80
+ hostname.nostat.mem : free => 1693290496
81
+ hostname.nostat.mem : buff => 0
82
+ hostname.nostat.mem : cach => 60887040
83
+ hostname.nostat.mem : used => 175230976
84
+
85
+ ...
86
+
87
+ ```
88
+
45
89
  ## it was tested on
46
- . CentOS 7.x (kernel 3.10.x)
90
+ . CentOS 7.x (kernel 3.10.x) with graphite
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: fluent-plugin-nostat 0.1.1 ruby lib
2
+ # stub: fluent-plugin-nostat 0.2.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-nostat"
6
- s.version = "0.1.1"
6
+ s.version = "0.2.1"
7
7
 
8
8
  s.require_paths = ["lib"]
9
9
  s.authors = ["No JinHo"]
@@ -1,3 +1,7 @@
1
+ #
2
+ # by nozino (nozino@gamil.com)
3
+ #
4
+
1
5
  module Fluent
2
6
  class NostatInput < Input
3
7
  Plugin.register_input('nostat', self)
@@ -27,6 +31,7 @@ module Fluent
27
31
  config_param :tag, :string, :default => nil
28
32
  config_param :run_interval, :time, :default => nil
29
33
  config_param :mode, :string, :default => "raw"
34
+ config_param :output_type, :string, :default => "hash"
30
35
 
31
36
  def configure(conf)
32
37
  super
@@ -35,7 +40,7 @@ module Fluent
35
40
  @tag = @tag_prefix + `hostname`.strip.split('.')[0].strip + ".nostat"
36
41
  end
37
42
  if !@run_interval
38
- raise ConfigError, "'run_interval' option is required on df input"
43
+ raise ConfigError, "'run_interval' option is required on nostat input"
39
44
  end
40
45
  end
41
46
 
@@ -217,6 +222,42 @@ module Fluent
217
222
  stat
218
223
  end
219
224
 
225
+ def emit_graphite_style (time, record)
226
+ # cpu
227
+ tag = @tag + ".cpu"
228
+ router.emit(tag, time, record["cpu"])
229
+
230
+ # memory
231
+ tag = @tag + ".mem"
232
+ router.emit(tag, time, record["mem"])
233
+
234
+ # disk
235
+ tag_prefix = @tag + ".disk"
236
+
237
+ record["disk"].each do |key, value|
238
+ tag = tag_prefix + "." + key
239
+ router.emit(tag, time, value)
240
+ end
241
+
242
+ # net
243
+ tag_prefix = @tag + ".net"
244
+
245
+ record["net"].each do |key, value|
246
+ tag = tag_prefix + "." + key
247
+ router.emit(tag, time, value)
248
+ end
249
+ end
250
+
251
+ def emit_record (time, record)
252
+ if @output_type == "graphite"
253
+ emit_graphite_style(time, record)
254
+ elsif @output_type == "hash"
255
+ router.emit(@tag, time, record)
256
+ else
257
+ log.error "invalid output_type. output_type=", @output_type
258
+ end
259
+ end
260
+
220
261
  def run_periodic
221
262
  until @finished
222
263
  begin
@@ -230,10 +271,10 @@ module Fluent
230
271
  record = stat
231
272
  end
232
273
 
233
- emit_tag = @tag.dup
234
274
  time = Engine.now
275
+
276
+ emit_record(time,record)
235
277
 
236
- router.emit(@tag, time, record)
237
278
  rescue => e
238
279
  log.error "nostat failed to emit", :error => e.to_s, :error_class => e.class.to_s, :tag => tag
239
280
  log.error "nostat to run or shutdown child process", :error => $!.to_s, :error_class => $!.class.to_s
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-nostat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - No JinHo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2016-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd