Class: Fluent::DockerInspectInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_docker_inspect.rb

Defined Under Namespace

Classes: TimerWatcher

Instance Method Summary collapse

Constructor Details

#initializeDockerInspectInput

Returns a new instance of DockerInspectInput.



14
15
16
17
18
19
20
21
22
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 14

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



46
47
48
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 46

def configure(conf)
  super
end

#on_timerObject



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 76

def on_timer
  time = Engine.now
  tag = @tag
  if @add_addr_tag && @host_addr
    tag = [tag, @host_addr].join(".")
  end

  get_inspect.each { | i |
    @es.add(time, i)
  }
  router.emit_stream(tag, @es)
end

#runObject



69
70
71
72
73
74
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 69

def run
  @loop.run
rescue => e
  log.error "unexpected error", :error=> e.to_s
  log.error_backtrace
end

#shutdownObject



61
62
63
64
65
66
67
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 61

def shutdown
  log.info "shutdown docker_inspect plugin"

  @loop.watchers.each {|w| w.detach }
  @loop.stop
  @thread.join
end

#startObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 50

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