bin/riemann-docker in riemann-docker-0.1.1 vs bin/riemann-docker in riemann-docker-0.1.2
- old
+ new
@@ -177,28 +177,39 @@
disk()
end
# Get CPU, Memory and Load of each container
containers = get_containers()
- containers.each do |container|
+ threads = []
- id = container.id
- name = get_container_name(container)
+ containers.each do |ctr|
+ threads << Thread.new(ctr) do |container|
- stats = Docker::Util.parse_json(container.connection.get("/containers/#{id}/stats", {stream:false}))
+ id = container.id
+ name = get_container_name(container)
- if @basic_inspection_enabled
- inspection = Docker::Util.parse_json(container.connection.get("/containers/#{id}/json"))
- basic_inspection(id, name, inspection)
+ stats = Docker::Util.parse_json(container.connection.get("/containers/#{id}/stats", {stream:false}))
+
+ if @basic_inspection_enabled
+ inspection = Docker::Util.parse_json(container.connection.get("/containers/#{id}/json"))
+ basic_inspection(id, name, inspection)
+ end
+ if @cpu_enabled
+ cpu(id, name, stats)
+ end
+ if @memory_enabled
+ memory(id, name, stats)
+ end
end
- if @cpu_enabled
- cpu(id, name, stats)
- end
- if @memory_enabled
- memory(id, name, stats)
- end
end
+ threads.each do |thread|
+ begin
+ thread.join
+ rescue => e
+ $stderr.puts "#{e.class} #{e}\n#{e.backtrace.join "\n"}"
+ end
+ end
end
end
Riemann::Tools::DockerHealth.run