From 109144ded5a70b753deb8f348d2ac779868d01b1 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Fri, 18 Sep 2020 12:11:41 +1000 Subject: [PATCH] [docker_] Get CPU count from os.cpu_count() everywhere Docker-py and os.cpu_count() disagree on the count, leading to data going beyond the scale of the graph. As Docker-py seems to have dummy CPU data in the stats, we instead always rely on Python's CPU count. Signed-off-by: Olivier Mehani --- plugins/docker/docker_ | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/docker/docker_ b/plugins/docker/docker_ index 6cf391c1..18328f04 100755 --- a/plugins/docker/docker_ +++ b/plugins/docker/docker_ @@ -260,14 +260,13 @@ def parallel_container_stats(client): def print_containers_cpu(client): for container, stats in parallel_container_stats(client): - cpu_count = len(stats["cpu_stats"]["cpu_usage"]["percpu_usage"]) cpu_percent = 0.0 cpu_delta = (float(stats["cpu_stats"]["cpu_usage"]["total_usage"]) - float(stats["precpu_stats"]["cpu_usage"]["total_usage"])) system_delta = (float(stats["cpu_stats"]["system_cpu_usage"]) - float(stats["precpu_stats"]["system_cpu_usage"])) if system_delta > 0.0: - cpu_percent = cpu_delta / system_delta * 100.0 * cpu_count + cpu_percent = cpu_delta / system_delta * 100.0 * os.cpu_count() print(container.name + '.value', cpu_percent) print(container.name + '.extinfo', container_attributes(container))