-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
I took a look to the documentation but by doing:
cli=docker.from_env()
server=cli.containers.run(...)
server.stats()
Output:
<generator..>
I didnt get the expected results. I was only able to get the stats with the low level API:
client=..
sts=client.stats(container=..)
and even under that command I didnt get the CPU and Memory percentages that sudo docker stats provides.
(sudo docker stats)
ID CPU CPU% Memory Memory% ..
Could you please provide the call to obtain the CPU and memory percentages, as it is not clear to me in the documentation.
Also I tried the following equation and I didnt obtained the same percentage as docker stats:
cpuDelta = (sts.CPUStats.CPUUsage.TotalUsage) - (previousCPU.CPUUsage.TotalUsage)
systemDelta = (v.CPUStats.SystemUsage) - (previousSystem.CPUStats.SystemUsage)
cpuPercent = float(cpuDelta / systemDelta) * float(len(sts.CPUStats.CPUUsage.PercpuUsage)) * 100.0