ualex73 / monitor_docker

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

Enhancement: regularly poll for new containers #60

Closed redpizza69 closed 1 month ago

redpizza69 commented 3 years ago

I would like to request an enhancement that would also fix several problems users are experiencing.

It appears that monitor_docker creates a list of containers to monitor when HomeAssistant starts up. You have the option of supplying the names of the containers to monitor, or to leave the "Containers" parameter unset in order for all known containers to be monitored. I would like to suggest that if the "Containers" parameter is left unset then monitor_docker will re-create the list of containers to monitor every 5 or 10 minutes.

There are several reasons for this request: 1) I believe monitor_docker stops monitoring a container after the first time it cannot connect to it. With many containers (above 20) to monitor and with the default scan_interval of 10 seconds, we are seeing timeouts leading to containers no longer being monitored, even though they are still active. The only way to resume monitoring them is to re-start HomeAssistant. 2) If a container is not started at HomeAssistant start time then it will not be monitored if it is started at a later date. 3) Containers that are re-started are not monitored. 4) New containers are only monitored after a HomeAssistant restart.

By re-creating the list of containers every 5 - 10 minutes, then all of the above situations would be fixed.

Thanks

ualex73 commented 3 years ago

At this moment de monitor_docker monitors through Docker API events if new containers are added (or if they are removed). I have seen people reporting issues e.g. portainer and the container is 'gone', only I am unable to reproduce it on my system (I need to find more time to try it again, hopefully until the problem is shown - or even try it on a Pi3/4).

The request itself is a big rewrite of the code, so it isn't something quickly done ... I am happy to review your PR, if you like to raise one.

ualex73 commented 1 month ago

This is a watchtower item. I will close this old issue. If still persists, please open a new issue.