Projet

Général

Profil

Révision 109144de

ID109144ded5a70b753deb8f348d2ac779868d01b1
Parent 5bb9b46e
Enfant 7f789c47

Ajouté par Olivier Mehani il y a environ 5 ans

[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 <>

Voir les différences:

plugins/docker/docker_
260 260

  
261 261
def print_containers_cpu(client):
262 262
    for container, stats in parallel_container_stats(client):
263
        cpu_count = len(stats["cpu_stats"]["cpu_usage"]["percpu_usage"])
264 263
        cpu_percent = 0.0
265 264
        cpu_delta = (float(stats["cpu_stats"]["cpu_usage"]["total_usage"])
266 265
                     - float(stats["precpu_stats"]["cpu_usage"]["total_usage"]))
267 266
        system_delta = (float(stats["cpu_stats"]["system_cpu_usage"])
268 267
                        - float(stats["precpu_stats"]["system_cpu_usage"]))
269 268
        if system_delta > 0.0:
270
            cpu_percent = cpu_delta / system_delta * 100.0 * cpu_count
269
            cpu_percent = cpu_delta / system_delta * 100.0 * os.cpu_count()
271 270
        print(container.name + '.value', cpu_percent)
272 271
        print(container.name + '.extinfo', container_attributes(container))
273 272

  

Formats disponibles : Unified diff