munin-monitoring / contrib

Contributed stuff for munin (plugins, tools, etc...)

Home Page:http://munin-monitoring.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker cpu is not using env.EXCLUDE_CONTAINER_NAME

ogmueller opened this issue · comments

The docker plugin should use env.EXCLUDE_CONTAINER_NAME as stated in the documentation of the plugin, but this is not used when e.g. munin-run docker_cpu is used.

The issue is in function containers(self), which is not filtering the cointainer list. It should do so using:

 124         return [c for c in self.client.containers.list()
 125                 if not self.exclude
 126                 or not self.exclude.search(c.name)]

instead of

 124         return self.client.containers.list()

Your recommendation for def containers(self) looks similar to the current code of def all_containers(self).
Maybe we should replace all(?) references to .containers with .all_containers?
(I cannot judge myself, since I do not use the plugin)

As far as I can see, the def containers is only called by munin-run docker_containers, which returns the total numbers of running/restarting containers like docker ps.

In contrast to that, all_containers will also retrieve other containers (e.g. paused, stopped, dead, exited, ...) like docker ps -a.

So both function might be neccessary, but they probably should filter the results depending on the exclusion list in env.EXCLUDE_CONTAINER_NAME.

I think, this is fixed now (a3ae1af), since all_containers is used everywhere in the plugin (and thus the filtering applies).

Please re-open, if you think, that something is missing.