ualex73 / monitor_docker

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

Entity already exists error #106

Closed eyalcha closed 1 month ago

eyalcha commented 1 year ago

After some time I am starting to see error logs when using remote dockermonitor (dockerproxy) and data is not received any more to the sensors

2022-08-16 08:09:49.790 ERROR (Thread-3 (RunDocker)) [custom_components.monitor_docker.helpers] [Docker2]: run_docker_events loop ended

2022-08-16 08:09:55.161 ERROR (MainThread) [custom_components.monitor_docker.sensor] [Docker2] frigate: Cannot determine network-available?

2022-08-16 08:09:55.216 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.docker2_version

2022-08-16 08:09:55.241 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.docker2_containers_running

2022-08-16 08:09:55.259 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.docker2_containers_total

2022-08-16 08:09:55.273 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.docker2_cpu

Note that after restarting Home Assistant, errors are gone and data is received, which means that the issue is not with the remote system, but with Home Assistant integration.

Zoeff commented 1 year ago

Having this issue as well. I left it on overnight and saw it recorded short intervals with long gaps between them. The above error appearing whenever the logging stops in the below screenshot. How did you fix this if at all?

DockerMonitor_Hickups 2022-12-30 22:06:38.943 ERROR (Thread-2 (RunDocker)) [custom_components.monitor_docker.helpers] [Docker] domoticz: Container not available anymore (3) (DockerError(900, 'Cannot connect to Docker Engine via tcp://192.168.178.XX:2375 [Server disconnected]'))

If this still needs fixing then for reference, I'm using a RBPi 4 with Raspberry Pi OS 64bit running HA in a container.

My docker-compose.yml for HA:

version: '3'
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /opt/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
    restart: unless-stopped
    privileged: true
    network_mode: host
   # devices:
   #   - "/dev/serial/by-id/usb-0658_0200-if00:/dev/serial/by-id/usb-0658_0200-if00"

The HA configuration.yml file includes this:

monitor_docker:
  - name: Docker
    url: tcp://192.168.178.XX:2375

(Real IP different of course)

And the dockerproxy docker-compose.yml file:

# Proxy the Docker sock so that we can pick up stats for HomeAssistant
dockerproxy:
  image: tecnativa/docker-socket-proxy
  container_name: dockerproxy
  privileged: true
  restart: unless-stopped
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  ports:
    - 2375:2375
  environment:
    - BUILD=1
    - COMMIT=1
    - CONFIGS=1
    - CONTAINERS=1
    - DISTRIBUTION=1
    - EXEC=1
    - IMAGES=1
    - INFO=1
    - NETWORKS=1
    - NODES=1
    - PLUGINS=1
    - SERVICES=1
    - SESSSION=1
    - SWARM=1
    - POST=1
ualex73 commented 1 year ago

@Zoeff your issue is different. You should monitor the network traffic, maybe the TCP/IP connection gets disconnected and that could be the cause. Depending on your findings, it is possible you need to fix your setup yourself (if it is outside the integration). I am not sure you can do a tcpdump, but if you got that - you can check which side closes the connection and when it accepts it again.

Zoeff commented 1 year ago

Looks like I can use tcpdump however I have zero expertise when it comes to TCP/IP connections or networking in general. I've tried filtering by port 2375 and there is something different happening around the time of the graph being cut off but I have no idea how to interpret it.

See here: logs_port2375 And the above section in graph form: logs_port2375_graph

Zoeff commented 1 year ago

Filtering by docker0 instead of by port 2375 showed this scary looking red entry right as the graph stopped updating in HomeAssistant: logs_docker0

ualex73 commented 1 month ago

This issue still persists with v1.18?

ualex73 commented 1 month ago

I will close this one, if it happens again, please raise a new issue.