Sanderhuisman / home-assistant-custom-components

🏡 Custom components for Home-Assistant
https://www.home-assistant.io/
Apache License 2.0
33 stars 12 forks source link

It can't be integrated on HA 0.96 #9

Closed TheRealBadRobot closed 5 years ago

TheRealBadRobot commented 5 years ago

The Docker monitor can not be integrated on Hassio HA 0,96 My config:

docker_monitor:
  containers:
    - homeassistant
    - xiaomi-aqara-rtsp
    - ha-dockermon
  monitored_conditions:
    - utilization_version
    - container_status
    - container_memory_usage
    - container_memory_percentage_usage
    - container_cpu_percentage_usage

Log Details (ERROR) Tue Jul 23 2019 11:58:29 GMT+0200 (közép-európai nyári idő) Error during setup of component docker_monitor Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen chunked=chunked) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/lib/python3.7/http/client.py", line 1244, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1290, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1239, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/local/lib/python3.7/http/client.py", line 966, in send self.connect() File "/usr/local/lib/python3.7/site-packages/docker/transport/unixconn.py", line 42, in connect sock.connect(self.unix_socket) FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 368, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen chunked=chunked) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/lib/python3.7/http/client.py", line 1244, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1290, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1239, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/local/lib/python3.7/http/client.py", line 966, in send self.connect() File "/usr/local/lib/python3.7/site-packages/docker/transport/unixconn.py", line 42, in connect sock.connect(self.unix_socket) urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 156, in _async_setup_component component.setup, hass, processed_config) # type: ignore File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, *self.kwargs) File "/config/custom_components/docker_monitor/init.py", line 115, in setup api = DockerAPI(host) File "/config/custom_components/docker_monitor/init.py", line 178, in init for container in self._client.containers.list(all=True) or []: File "/usr/local/lib/python3.7/site-packages/docker/models/containers.py", line 918, in list since=since) File "/usr/local/lib/python3.7/site-packages/docker/api/container.py", line 208, in containers res = self._result(self._get(u, params=params), True) File "/usr/local/lib/python3.7/site-packages/docker/utils/decorators.py", line 46, in inner return f(self, args, kwargs) File "/usr/local/lib/python3.7/site-packages/docker/api/client.py", line 225, in _get return self.get(url, self._set_request_timeout(kwargs)) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 546, in get return self.request('GET', url, kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

ualex73 commented 5 years ago

Did it work before 0.96? Also you need to expose it properly in docker, otherwise it won't work: -v /var/run/docker.sock:/var/run/docker.sock

TheRealBadRobot commented 5 years ago

It is a new install and I guess I missunderstood something, it is my mistake. I have installed the Ha dockermon with -v /var/run/docker.sock:/var/run/docker.sock and I tought it is eonugh ("The monitor is based on Glances and ha-dockermon and combines "). I'm not an expert so I don't know how can I expose it.

BOZG commented 5 years ago

You need to expose the Docker socket in your Home Assistant container so use -v /var/run/docker.sock:/var/run/docker.sock when running HA.

There are security issues with exposing the Docker socket though so you should look into using a Docker socket proxy instead.

TheRealBadRobot commented 5 years ago

Sorry but it is Klingon for me :) Have I add it to home assistant container? Sorry but I'm really greenhorn in the docker things.

TheRealBadRobot commented 5 years ago

Morphy99 helped me to solve the problem.