sensu-plugins / sensu-plugins-docker

This plugin provides native Docker instrumentation for monitoring and metrics collection, including: container status, container number, and container metrics via `docker ps`.
http://sensu-plugins.io
MIT License
35 stars 57 forks source link

Check commands fail with remote docker host #65

Open sjthespian opened 6 years ago

sjthespian commented 6 years ago

I just installed sensu-docker-plugins and it is working great with the local host, but I can't check remote docker hosts. It is failing with getaddrinfo() errors even if I specify an IP, which seems odd. Running docker commands with the docker CLI and DOCKER_HOST set works fine for the same remote host.

I have tried various combinations of hostname, fqdn, and ip; both with and without protocol and port with no luck. Using the -Y option the commands fail with in getaddrinfo(). If I try and use the environment variable it fails in sub().

I'm on sensu 1.2.1 with version 3.1.0 of the plugin.

For example:

> DOCKER_HOST=172.16.xxx.yyy docker ps
CONTAINER ID        IMAGE                                           COMMAND                  CREATED             STATUS                    PORTS                                                                        NAMES
... list of docker processes ...

> /opt/sensu/embedded/bin/check-docker-container.rb -H 172.16.xxx.yyy
Check failed to run: Failed to open TCP connection to http://172.16.xxx.yyy:2375 (getaddrinfo: Name or service not known), ["/opt/sensu/embedded/lib/ruby/2.4.0/net/http.rb:906:in `rescue in block in connect'", "/opt/sensu/embedded/lib/ruby/2.4.0/net/http.rb:903:in `block in connect'", "/opt/sensu/embedded/lib/ruby/2.4.0/timeout.rb:93:in `block in timeout'", "/opt/sensu/embedded/lib/ruby/2.4.0/timeout.rb:103:in `timeout'", "/opt/sensu/embedded/lib/ruby/2.4.0/net/http.rb:902:in `connect'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/net_http_unix-0.2.2/lib/net_x/http_unix.rb:26:in `connect'", "/opt/sensu/embedded/lib/ruby/2.4.0/net/http.rb:887:in `do_start'", "/opt/sensu/embedded/lib/ruby/2.4.0/net/http.rb:882:in `start'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-docker-3.1.0/lib/sensu-plugins-docker/client_helpers.rb:21:in `initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-docker-3.1.0/bin/check-docker-container.rb:104:in `new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-docker-3.1.0/bin/check-docker-container.rb:104:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.5.0/lib/sensu-plugin/cli.rb:57:in `block in <class:CLI>'"]

> DOCKER_HOST=172.16.xxx.yyy /opt/sensu/embedded/bin/check-container.rb -N flexget
Check failed to run: can't modify frozen String, ["/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-docker-3.1.0/lib/sensu-plugins-docker/client_helpers.rb:8:in `sub!'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-docker-3.1.0/lib/sensu-plugins-docker/client_helpers.rb:8:in `initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-docker-3.1.0/bin/check-container.rb:66:in `new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-docker-3.1.0/bin/check-container.rb:66:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.5.0/lib/sensu-plugin/cli.rb:57:in `block in <class:CLI>'"]