Class: Fluent::SpecinfraInventoryInput
- Inherits:
-
Input
- Object
- Input
- Fluent::SpecinfraInventoryInput
- Defined in:
- lib/fluent/plugin/in_specinfra_inventory.rb
Constant Summary collapse
- KEY_DELIMITER =
"."
Instance Attribute Summary collapse
-
#inventory ⇒ Object
Returns the value of attribute inventory.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ SpecinfraInventoryInput
constructor
A new instance of SpecinfraInventoryInput.
- #record(key) ⇒ Object
- #run ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #tag(key) ⇒ Object
Constructor Details
#initialize ⇒ SpecinfraInventoryInput
Returns a new instance of SpecinfraInventoryInput.
22 23 24 25 26 |
# File 'lib/fluent/plugin/in_specinfra_inventory.rb', line 22 def initialize super require 'specinfra' require 'specinfra/host_inventory' end |
Instance Attribute Details
#inventory ⇒ Object
Returns the value of attribute inventory.
20 21 22 |
# File 'lib/fluent/plugin/in_specinfra_inventory.rb', line 20 def inventory @inventory end |
Instance Method Details
#configure(conf) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fluent/plugin/in_specinfra_inventory.rb', line 28 def configure(conf) super Specinfra.configuration.send(:backend, @backend.to_sym) Specinfra.configuration.send(:path, @path) if @path Specinfra.configuration.send(:host, @host) if @host Specinfra.configuration.send(:env, @env) if @env opt = {} opt[:family] = @family if @family opt[:release] = @release if @release opt[:arch] = @arch if @arch Specinfra.configuration.send(:os, opt) if opt.length > 0 opt = {} opt[:user] = @ssh_user if @ssh_user opt[:port] = @ssh_port if @ssh_port Specinfra.configuration.send(:ssh_options, opt) if opt.length > 0 @inventory = Specinfra::HostInventory.instance end |
#record(key) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/fluent/plugin/in_specinfra_inventory.rb', line 74 def record(key) inv = @inventory key.split(KEY_DELIMITER).each do |k| inv = inv[k] end inv end |
#run ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/fluent/plugin/in_specinfra_inventory.rb', line 60 def run loop do time = Engine.now @inventory_keys.each do |key| Engine.emit(tag(key), time, record(key)) end sleep @timespan end end |
#shutdown ⇒ Object
55 56 57 58 |
# File 'lib/fluent/plugin/in_specinfra_inventory.rb', line 55 def shutdown @finished = true @thread.join end |
#start ⇒ Object
50 51 52 53 |
# File 'lib/fluent/plugin/in_specinfra_inventory.rb', line 50 def start @finished = false @thread = Thread.new(&method(:run)) end |
#tag(key) ⇒ Object
70 71 72 |
# File 'lib/fluent/plugin/in_specinfra_inventory.rb', line 70 def tag(key) "#{@tag_prefix}.#{key}" end |