ualex73 / monitor_docker

Monitor Docker containers from Home Assistant
Apache License 2.0
268 stars 34 forks source link

Container Running or not #14

Closed nytram-md closed 3 years ago

nytram-md commented 4 years ago

Hi

Not sure if I have missed the variable but is there a way to see if the container is running or turned off rather than up 9 days for example. Id rather see running or off

I also have this notification but the switches that have been created all work OK

image

Keep up the good work

Thanks

Martyn

ualex73 commented 4 years ago

It exist, but it wasn't document (oeps!). Change "status" to "state" and you should be there.

Not sure what that type of error is, does the log say anything useful?

ualex73 commented 4 years ago

I also updated the README file to reflect the "state" info ;-)

nytram-md commented 4 years ago

Hi

Thanks for that. appreciate it.

Ive just upgraded to v 0.112.0 and docker seems to have removed the /var/run/docker.sock:/var/run/docker.sock bind that I had this afternoon when it was all working. Do you want me to create a new issue and move or is it OK here ?

image

image

nytram-md commented 4 years ago

re binded the /var/run/docker.sock in portainer and all working again but I now have the switch issue again. Will I have to do this after every upgrade ?

Can you see anything wrong with my code as nothing in the logs that I can see?

Thanks again

`monitor_docker:

nytram-md commented 4 years ago

Just found this log which may help for the switch issue. Its happened in 0.111.4 and 0.112.0

`Log Details (ERROR) Logger: homeassistant.components.rest.sensor Source: components/rest/sensor.py:113 Integration: rest (documentation, issues) First occurred: 0:00:33 (60 occurrences) Last logged: 0:08:11

Error fetching data: http://192.168.0.11:8126/container/homeassistant failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/homeassistant (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f828d3db290>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/docker_cloudflare-ddns_1 failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/docker_cloudflare-ddns_1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f828d3ddad0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/docker_ghost_1 failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/docker_ghost_1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8275feedd0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/letsencrypt failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/letsencrypt (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8275fee5d0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/docker_db_1 failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/docker_db_1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8275fec8d0>: Failed to establish a new connection: [Errno 111] Connection refused'))`

ualex73 commented 4 years ago

re binded the /var/run/docker.sock in portainer and all working again but I now have the switch issue again. Will I have to do this after every upgrade ?

Can you see anything wrong with my code as nothing in the logs that I can see?

Thanks again

`monitor_docker:

* name: Docker
  containers:

  * letsencrypt
  * docker_db_1
  * docker_ghost_1
  * docker_cloudflare-ddns_1
  * ha_dockermon
  * homeassistant
    rename:
    letsencrypt: Webserver
    docker_db_1: MYSQL
    docker_ghost_1: "Ghost Blogg"
    docker_cloudflare-ddns_1: "Cloudflare DNS"
    ha_dockermon: "HA Docker Monitor"
    homeassistant: "Home Assistant"
    monitored_conditions:
  * version
  * containers_running
  * containers_stopped
  * containers_total
  * status
  * state
  * memory
  * uptime`

This is a Docker upgrade issue, it isn't a monitor_docker problem. I am not sure how you create a new Home Assistant container? I myself use docker-compose and then it is automatically picked up during each upgrade (cannot access my config, so i cannot copy-paste it).

ualex73 commented 4 years ago

Just found this log which may help for the switch issue. Its happened in 0.111.4 and 0.112.0

`Log Details (ERROR) Logger: homeassistant.components.rest.sensor Source: components/rest/sensor.py:113 Integration: rest (documentation, issues) First occurred: 0:00:33 (60 occurrences) Last logged: 0:08:11

Error fetching data: http://192.168.0.11:8126/container/homeassistant failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/homeassistant (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f828d3db290>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/docker_cloudflare-ddns_1 failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/docker_cloudflare-ddns_1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f828d3ddad0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/docker_ghost_1 failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/docker_ghost_1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8275feedd0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/letsencrypt failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/letsencrypt (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8275fee5d0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/docker_db_1 failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/docker_db_1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8275fec8d0>: Failed to establish a new connection: [Errno 111] Connection refused'))`

Hmmm... according to the error, it cannot connect to the TCP of the remote docker host (connection refused). In such case switches and sensors both shouldn't work. That connection refused you need to solve first, before you continue with monitor_docker.

nytram-md commented 4 years ago

Hi

No problems if I just need to add the mount now I know.

Does the log help for the switches issue ?

Martyn

Regards

Martyn


From: Alexander notifications@github.com Sent: Thursday, July 2, 2020 8:31:29 AM To: ualex73/monitor_docker monitor_docker@noreply.github.com Cc: nytram-md martyn_dickinson@hotmail.com; Author author@noreply.github.com Subject: Re: [ualex73/monitor_docker] Container Running or not (#14)

re binded the /var/run/docker.sock in portainer and all working again but I now have the switch issue again. Will I have to do this after every upgrade ?

Can you see anything wrong with my code as nothing in the logs that I can see?

Thanks again

`monitor_docker:

This is a Docker upgrade issue, it isn't a monitor_docker problem. I am not sure how you create a new Home Assistant container? I myself use docker-compose and then it is automatically picked up during each upgrade (cannot access my config, so i cannot copy-paste it).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ualex73/monitor_docker/issues/14#issuecomment-652837335, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANHZVQECOTASDEDRKU4CIZ3RZQZVDANCNFSM4ONRKTTA.

nytram-md commented 4 years ago

The switches work though. I turned off a container last night as i originally used phil Hawthornes HA Docker Mon, so had a container I could turn off. I liked yours more as it was in HACS and had more sensors. [Image]

Regards

Martyn


From: Alexander notifications@github.com Sent: Thursday, July 2, 2020 8:32:50 AM To: ualex73/monitor_docker monitor_docker@noreply.github.com Cc: nytram-md martyn_dickinson@hotmail.com; Author author@noreply.github.com Subject: Re: [ualex73/monitor_docker] Container Running or not (#14)

Just found this log which may help for the switch issue. Its happened in 0.111.4 and 0.112.0

`Log Details (ERROR) Logger: homeassistant.components.rest.sensor Source: components/rest/sensor.py:113 Integration: rest (documentation, issues) First occurred: 0:00:33 (60 occurrences) Last logged: 0:08:11

Error fetching data: http://192.168.0.11:8126/container/homeassistant failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/homeassistant (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f828d3db290>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/docker_cloudflare-ddns_1 failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/docker_cloudflare-ddns_1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f828d3ddad0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/docker_ghost_1 failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/docker_ghost_1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8275feedd0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/letsencrypt failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/letsencrypt (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8275fee5d0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error fetching data: http://192.168.0.11:8126/container/docker_db_1 failed with HTTPConnectionPool(host='192.168.0.11', port=8126): Max retries exceeded with url: /container/docker_db_1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8275fec8d0>: Failed to establish a new connection: [Errno 111] Connection refused'))`

Hmmm... according to the error, it cannot connect to the TCP of the remote docker host (connection refused). In such case switches and sensors both shouldn't work. That connection refused you need to solve first, before you continue with monitor_docker.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ualex73/monitor_docker/issues/14#issuecomment-652837963, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANHZVQFEOWGTAR5FHW4DORDRZQZ2FANCNFSM4ONRKTTA.

ualex73 commented 4 years ago

I can't see the issue with the switches at this moment?

malinduta commented 3 years ago

Same issue here regarding the switches. Working to start/stop containers, but throws error when starting HA.

ualex73 commented 3 years ago

@malinduta please open a new issue and please include error and possible debug logging, without it, I can't do much with it.

ualex73 commented 3 years ago

@nytram-md in version 1.2 the switch error is solved (was a strange reason, not related to the code)