monitor_docker
monitor_docker copied to clipboard
Swarm Mode Addition?
I really like this, being able to trigger an alert to display on kodi when a container has finished/failed
But i cannot get services to show up. I used the containers: with no containers listed so it shows all containers, and the swarm/services based containers only show as the container with the task id.
home-assistant.1.9ki34z5buqhvnfgg9lskyjxe0
and not
home-assistant as the servicename is set.
Is it possible to add this functionality?? I have a mixture of containers and services running and this would be the icing on the cake!
thanks
I am not familiar with the Swarm mode, but could it work if the container name list would be an expression? Like "home-assistant.*" will then match home-assistant.1.9ki34etc
Specifying up to the first separator . would work, everything after the first period is random from this point of view. The .1. Is the replication number and after the second it’s just a random task number. Seeing it just makes HA very messy :)
Any chance or anyone who has tried to use it in a swarm config? Like the first post each container has an ID, so renaming wouldn't work out of the box i guess unless it's changed with wildcards?
But how can I get information from each host into monitor_docker? would there be a way to use several proxies and as such have them all refered too?
Would love to have an overview off my cluster, in case something is wrong I can trigger on that.
Thanks.
I'm here to ask the same or similar question: For those using Swarm mode, would it be possible to detect that with trimming the container name to the left of the .1.*
? The problem I see is with the HA sensors populating with the unique name, if a container restarts, it'll be a new sensor in HA.
Another possibility is if the rename:
function supported wildcards, one could do something like
rename:
SomeStack*: "Some Stack"
The only gotcha there would be if you had more than one replica in your stack, and/or if it also detected failed/redeployed tasks from that stack, then you have more than one match.
I made some changes in the repository, can you pick up the latest "sensor.py"and "switch.py" and try it out, now e.g.:
rename:
hass*: Home Assistant
Should work.
The rename works however the moment you want to add the sensors into HA, you get the list of all the container variables and not the container that is really active and as dockers will change with a new ID, the sensor will be broken. So this is not a working solution yet in swarm mode. Since i'm running in Swarm mode, i haven't tested yet to run it on all nodes but it seems I would have to add all the possible containers in the config per node, instead of a general container list? Any chance to split up the socket access and the container list?
Is there any new status on this?
So i've tested further and the problem is that the renaming is only done on the general name and not on the ID. Result is that you still get these long names in HA as ID tag but with the shortened name. The downside of these random chars is that each time a new container is made, the unique id is recreated and as such you get different information. So far I've changed the unique id to be the alias so it's more "logic" to read, the only downside is that if the same container exists or used to exist can give some wrong information as it will see the same "ID". it's not ideal but at least it's more readable now with only 1 time the container. I've added all my hosts with dockerproxy and read them info this way. the only thing that seems to be miss is that the list of containers won't work in this scenario as the ID is a random char and not the list of container. Could you add the same wildcard search in the list of containers too? I've tried looking at it but not sure where to adapt.