fluent-plugin-df 0.0.3 → 0.0.4

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.
data/README.md CHANGED
@@ -20,20 +20,25 @@ Or install it yourself as:
20
20
 
21
21
  <source>
22
22
  type df
23
- option -k
24
- interval 3
25
- tag_prefix df
26
- target_mounts /
23
+ option -k # df command options
24
+ interval 3 # execution interval of the df command
25
+ tag_prefix df # prefix of tag
26
+ target_mounts / # "Mounted on" to filter the information you want to retrieve
27
+ replace_slash true # whether to replace '_' by '/' in the file system
28
+ # tag free_disk # tag (default is nil)
27
29
  </source>
28
30
 
29
31
  If you specify more than one `target_mounts`, separated by spaces.
30
32
 
31
33
  ## Output Format
32
34
 
33
- df._dev_disk0s2: {"size":"487546976","used":"52533512","available":"434757464","capacity":"11"}
35
+ 2013-03-01 00:00:00 +0900 df._dev_disk0s2: {"size":"487546976","used":"52533512","available":"434757464","capacity":"11"}
34
36
 
35
- Tag name is the concatenation of the name of the `tag_prefix` and file system.
36
- `/` in the file system is replaced by an `_`
37
+ If `tag` specified, character of `tag` is the Tag name.
38
+
39
+ Otherwise, Tag name is the concatenation of the name of the `tag_prefix` and file system.
40
+
41
+ `/` in the file system is replaced by an `_`, if `replace_slash` is true.
37
42
 
38
43
  ## Contributing
39
44
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-df"
7
- spec.version = "0.0.3"
7
+ spec.version = "0.0.4"
8
8
  spec.authors = ["tiwakawa"]
9
9
  spec.email = ["tiwakawa@aiming-inc.com"]
10
10
  spec.description = %q{Df input plugin for Fluent event collector}
@@ -6,6 +6,8 @@ module Fluent
6
6
  config_param :interval, :integer, default: 3
7
7
  config_param :tag_prefix, :string, default: 'df'
8
8
  config_param :target_mounts, :string, default: '/'
9
+ config_param :replace_slash, :bool, default: true
10
+ config_param :tag, :string, default: nil
9
11
 
10
12
  def configure(conf)
11
13
  super
@@ -41,7 +43,7 @@ module Fluent
41
43
  fss.map do |fs|
42
44
  f = fs.split(/\s+/)
43
45
  {
44
- 'fs' => f[0].gsub(/\//, '_'),
46
+ 'fs' => replace_slash_in(f[0]),
45
47
  'size' => f[1],
46
48
  'used' => f[2],
47
49
  'available' => f[3],
@@ -50,8 +52,12 @@ module Fluent
50
52
  end
51
53
  end
52
54
 
55
+ def replace_slash_in(fs)
56
+ @replace_slash ? fs.gsub(/\//, '_') : fs
57
+ end
58
+
53
59
  def tag_name(fs)
54
- @tag_prefix.empty? ? fs : "#{@tag_prefix}.#{fs}"
60
+ @tag || (@tag_prefix.empty? ? fs : "#{@tag_prefix}.#{fs}")
55
61
  end
56
62
 
57
63
  def watch
@@ -10,6 +10,8 @@ class DfInputTest < Test::Unit::TestCase
10
10
  interval 3
11
11
  tag_prefix df
12
12
  target_mounts /
13
+ replace_slash true
14
+ tag free_disk
13
15
  ]
14
16
 
15
17
  def create_driver(conf=CONFIG)
@@ -18,10 +20,12 @@ class DfInputTest < Test::Unit::TestCase
18
20
 
19
21
  def test_configure
20
22
  d = create_driver
21
- assert_equal "-k", d.instance.option
22
- assert_equal "df", d.instance.tag_prefix
23
- assert_equal 3, d.instance.interval
24
- assert_equal "/", d.instance.target_mounts
23
+ assert_equal "-k", d.instance.option
24
+ assert_equal "df", d.instance.tag_prefix
25
+ assert_equal 3, d.instance.interval
26
+ assert_equal "/", d.instance.target_mounts
27
+ assert_equal true, d.instance.replace_slash
28
+ assert_equal "free_disk", d.instance.tag
25
29
  end
26
30
 
27
31
  # def test_emit
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-df
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: