Skip to content

cpu_usage in DockerMachineStats is always 0 due to incorrect computation #361

@tcaiazzi

Description

@tcaiazzi

Currently, the cpu_usage value reported in DockerMachineStats is always 0, which indicates that the CPU usage is not being computed correctly.

This appears to be caused by an incorrect or incomplete implementation of the CPU usage calculation logic, possibly not following Docker’s standard approach to compute it from container stats.

if "system_cpu_usage" in updated_stats["cpu_stats"]:
cpu_usage = updated_stats["cpu_stats"]["cpu_usage"]["total_usage"] / \
updated_stats["cpu_stats"]["system_cpu_usage"]
self.cpu_usage = f"{cpu_usage:.2f}%"

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions