mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
[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 <shtrom@ssji.net>
This commit is contained in:
parent
5bb9b46e08
commit
109144ded5
1 changed files with 1 additions and 2 deletions
|
@ -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))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue