Class: Fluent::DockerInspectInput
- Inherits:
-
Input
- Object
- Input
- Fluent::DockerInspectInput
- Defined in:
- lib/fluent/plugin/in_docker_inspect.rb
Defined Under Namespace
Classes: TimerWatcher
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ DockerInspectInput
constructor
A new instance of DockerInspectInput.
- #on_timer ⇒ Object
- #run ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ DockerInspectInput
Returns a new instance of DockerInspectInput.
16 17 18 19 20 21 22 23 24 |
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 16 def initialize super require 'json' require 'docker' require 'socket' Docker.url = @docker_url if @docker_url @host_addr = get_ipaddress end |
Instance Method Details
#configure(conf) ⇒ Object
48 49 50 |
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 48 def configure(conf) super end |
#on_timer ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 78 def on_timer time = Engine.now tag = @tag if @add_addr_tag && @host_addr tag = [tag, @host_addr].join(".") end inspect = get_inspect if inspect.length == 0 return end inspect.each { | i | @es.add(time, i) } router.emit_stream(tag, @es) end |
#run ⇒ Object
71 72 73 74 75 76 |
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 71 def run @loop.run rescue => e log.error "unexpected error", :error=> e.to_s log.error_backtrace end |
#shutdown ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 63 def shutdown log.info "shutdown docker_inspect plugin" @loop.watchers.each {|w| w.detach } @loop.stop @thread.join end |
#start ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 52 def start @started_at = Time.now.to_i @loop = Coolio::Loop.new @timer = TimerWatcher.new(@emit_interval, true, log, &method(:on_timer)) @loop.attach(@timer) @thread = Thread.new(&method(:run)) @es = MultiEventStream.new end |