fluent-plugin-specinfra_inventory 0.0.1 → 0.0.2

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: e40de8d848e26a71a26c212ed59acb2859137db3
4
- data.tar.gz: 2d0e70c4e86e30311a606f38fd3e40374c84df82
3
+ metadata.gz: c35a9f933b74336ff3368f97af2aa0b395900ca5
4
+ data.tar.gz: 97e3626f3e103d249fb71c9d5372175cd63e1f25
5
5
  SHA512:
6
- metadata.gz: 8b4287f1e14a392579eed53bed1d01e2255a0472bcf928b8a1f9c83fbdd4337d2e5b206778fe45409b46aacdf246378d4d50414cca081fa96cd842bf1fe91ed4
7
- data.tar.gz: 782dae04b88ee21be1a72b401ef081697026eafb7afa0e2fc0357d6b8b5c527b16627329307f2b3242aae8ceb3963c04dace48448e842f66ef488d75a618eed3
6
+ metadata.gz: b60860e63defc7b0768512ffc7c076e9df51b71f64a5751a23871efe4cf2a8f9a94a577f0921a96c9f1bcd38413602dd2599d6575e70c2c8fe2ac88723b2a332
7
+ data.tar.gz: 81ef6e0ea37192b585d6562874a7c0af2b3d36626d15b1a3c27fedfa0bede4c6ca0baad884c304e42bf42a767d6d9541d866fa746ac25461876b7c845491d64b
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 0.0.2
2
+
3
+ * Support nested Hash in inventory
4
+
5
+ ## 0.0.1
6
+
7
+ * Initial release
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # fluent-plugin-specinfra_inventory
2
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-specinfra_inventory.svg)](http://badge.fury.io/rb/fluent-plugin-specinfra_inventory)
2
3
 
3
4
  Specinfra Host Inventory Plugin for [Fluentd](http://github.com/fluent/fluentd)
4
5
 
@@ -25,7 +26,7 @@ Or install it yourself as:
25
26
  time_span 300
26
27
  tag_prefix example.prefix
27
28
  backend exec
28
- inventory_keys ["cpu","memory"]
29
+ inventory_keys ["cpu.total","memory"]
29
30
  family ubuntu
30
31
  release 14.04
31
32
  arch x86_64
@@ -47,21 +48,22 @@ Event tags are added together inventory key at the end. like: `example.prefix.cp
47
48
  default: `specinfra.inventory`
48
49
 
49
50
  ### backend
50
- Specinfra backend type
51
+ Specinfra backend type.
51
52
  default: `exec`
52
53
 
53
54
 
54
55
  ### inventory_keys
55
- Key of Host Inventory
56
+ Key of Host Inventory.
57
+ If you access the key on nested Hash, you should separated by `.`
56
58
 
57
59
  ### family, release, arch
58
60
  See [Multi OS Support](http://serverspec.org/tutorial.html)
59
61
 
60
62
  ### path
61
- `PATH` environment variable
63
+ Environment variable `PATH`
62
64
 
63
65
  ### host
64
- Target host
66
+ Target hostname or IP
65
67
 
66
68
  ### ssh_user
67
69
  SSH user name
@@ -15,6 +15,10 @@ module Fluent
15
15
  config_param :env, :hash, default: {}
16
16
  config_param :inventory_keys, :array
17
17
 
18
+ KEY_DELIMITER = "."
19
+
20
+ attr_accessor :inventory
21
+
18
22
  def initialize
19
23
  super
20
24
  require 'specinfra'
@@ -68,7 +72,11 @@ module Fluent
68
72
  end
69
73
 
70
74
  def record(key)
71
- @inventory[key]
75
+ inv = @inventory
76
+ key.split(KEY_DELIMITER).each do |k|
77
+ inv = inv[k]
78
+ end
79
+ inv
72
80
  end
73
81
 
74
82
  end
@@ -1,7 +1,7 @@
1
1
  module Fluent
2
2
  module Plugin
3
3
  module SpecinfraInventory
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -5,6 +5,14 @@ describe Fluent::SpecinfraInventoryInput do
5
5
  before do
6
6
  Fluent::Test.setup
7
7
  @d = Fluent::Test::InputTestDriver.new(Fluent::SpecinfraInventoryInput).configure(config)
8
+ @d.instance.inventory = {
9
+ 'cpu' => {
10
+ 'total' => "2",
11
+ '0' => {
12
+ 'vendor_id' => "1"
13
+ }
14
+ }
15
+ }
8
16
  end
9
17
 
10
18
  let(:config) do
@@ -12,7 +20,7 @@ describe Fluent::SpecinfraInventoryInput do
12
20
  time_span 300
13
21
  tag_prefix test.prefix
14
22
  backend exec
15
- inventory_keys ["cpu"]
23
+ inventory_keys ["cpu.0"]
16
24
  family ubuntu
17
25
  release 14.04
18
26
  arch x86_64
@@ -28,7 +36,7 @@ describe Fluent::SpecinfraInventoryInput do
28
36
  example { expect(@d.instance.time_span).to eq 300 }
29
37
  example { expect(@d.instance.tag_prefix).to eq "test.prefix" }
30
38
  example { expect(@d.instance.backend).to eq "exec" }
31
- example { expect(@d.instance.inventory_keys).to eq ["cpu"] }
39
+ example { expect(@d.instance.inventory_keys).to eq ["cpu.0"] }
32
40
  example { expect(@d.instance.family).to eq "ubuntu" }
33
41
  example { expect(@d.instance.release).to eq "14.04" }
34
42
  example { expect(@d.instance.arch).to eq "x86_64" }
@@ -43,7 +51,11 @@ describe Fluent::SpecinfraInventoryInput do
43
51
  example { expect(@d.instance.tag("cpu")).to eq "test.prefix.cpu" }
44
52
  end
45
53
 
46
- describe "record" do
47
- example { expect(@d.instance.record("cpu")).to have_key "total" }
54
+ describe "record on flat hash" do
55
+ example { expect(@d.instance.record("cpu")).to include('total' => "2") }
56
+ end
57
+
58
+ describe "record on nested hash" do
59
+ example { expect(@d.instance.record("cpu.0")).to include('vendor_id' => "1") }
48
60
  end
49
61
  end
data/spec/spec_helper.rb CHANGED
@@ -4,8 +4,6 @@ Coveralls.wear!
4
4
  require 'fluent/load'
5
5
  require 'fluent/test'
6
6
 
7
- require 'fluent/plugin/in_specinfra_inventory'
8
-
9
7
  RSpec.configure do |config|
10
8
  # rspec-expectations config goes here. You can use an alternate
11
9
  # assertion/expectation library such as wrong or the stdlib/minitest
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-specinfra_inventory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masashi Terui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -104,6 +104,7 @@ files:
104
104
  - ".gitignore"
105
105
  - ".rspec"
106
106
  - ".travis.yml"
107
+ - CHANGELOG.md
107
108
  - Gemfile
108
109
  - LICENSE.txt
109
110
  - README.md