mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
Merge pull request #1499 from rwky/docker-fix
Fixed bugs in docker plugin
This commit is contained in:
commit
2157586c7f
1 changed files with 8 additions and 2 deletions
|
@ -127,7 +127,7 @@ class ClientWrapper:
|
||||||
and support caching.
|
and support caching.
|
||||||
|
|
||||||
In addition, when the exclude_re parameter is not None,
|
In addition, when the exclude_re parameter is not None,
|
||||||
any container which name is matched by the RE will not be excluded from reports.
|
any container which name is matched by the RE will be excluded from reports.
|
||||||
"""
|
"""
|
||||||
client = None
|
client = None
|
||||||
exclude = None
|
exclude = None
|
||||||
|
@ -146,7 +146,7 @@ class ClientWrapper:
|
||||||
def all_containers(self):
|
def all_containers(self):
|
||||||
return [
|
return [
|
||||||
c for c in self.client.containers.list(all=True)
|
c for c in self.client.containers.list(all=True)
|
||||||
if (c.status == 'running') and (not self.exclude or not self.exclude.search(c.name))
|
if not self.exclude or not self.exclude.search(c.name)
|
||||||
]
|
]
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
@ -281,6 +281,8 @@ def parallel_container_stats(client):
|
||||||
proc_list = []
|
proc_list = []
|
||||||
stats = {}
|
stats = {}
|
||||||
for container in client.all_containers:
|
for container in client.all_containers:
|
||||||
|
if container.status != 'running':
|
||||||
|
continue
|
||||||
q = Queue()
|
q = Queue()
|
||||||
p = Process(target=get_container_stats, args=(container, q))
|
p = Process(target=get_container_stats, args=(container, q))
|
||||||
proc_list.append({'proc': p, 'queue': q, 'container': container})
|
proc_list.append({'proc': p, 'queue': q, 'container': container})
|
||||||
|
@ -292,7 +294,11 @@ def parallel_container_stats(client):
|
||||||
|
|
||||||
|
|
||||||
def print_containers_size(client):
|
def print_containers_size(client):
|
||||||
|
include_containers = [container.id for container in client.all_containers]
|
||||||
for container in client.api.df()['Containers']:
|
for container in client.api.df()['Containers']:
|
||||||
|
# exclude containers not in all_containers
|
||||||
|
if container['Id'] not in include_containers:
|
||||||
|
continue
|
||||||
size = container['SizeRw'] if 'SizeRw' in container else 0
|
size = container['SizeRw'] if 'SizeRw' in container else 0
|
||||||
# first char of name is always / so we skip it
|
# first char of name is always / so we skip it
|
||||||
clean_container_name = clean_fieldname(container['Names'][0][1:])
|
clean_container_name = clean_fieldname(container['Names'][0][1:])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue