Closed
Description
When I read source code about " docker stat", the current is :
cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CpuStats.CpuUsage.PercpuUsage))
https://github.com/docker/docker/blob/0d445685b8d628a938790e50517f3fb949b300e0/api/client/stats.go#L199
I do not understand why " * float64(len(v.CpuStats.CpuUsage.PercpuUsage)) ", (cpuDelta / systemDelta) is Correct。
cpuDelta = float64(v.CpuStats.CpuUsage.TotalUsage - previousCPU)
systemDelta = float64(v.CpuStats.SystemUsage - previousSystem)
so total cpu delta / total system delta is correct , not need to multiplied by CPU kernal count.
Am I think right?
Metadata
Metadata
Assignees
Labels
No labels
Activity
GordonTheTurtle commentedon Jun 1, 2015
Hi!
Please read this important information about creating issues.
If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead.
If you suspect your issue is a bug, please edit your issue description to include the BUG REPORT INFORMATION shown below. If you fail to provide this information within 7 days, we cannot debug your issue and will close it. We will, however, reopen it if you later provide the information.
This is an automated, informational response.
Thank you.
For more information about reporting issues, see https://github.com/docker/docker/blob/master/CONTRIBUTING.md#reporting-other-issues
BUG REPORT INFORMATION
Use the commands below to provide key information from your environment:
docker version
:docker info
:uname -a
:Provide additional environment details (AWS, VirtualBox, physical, etc.):
List the steps to reproduce the issue:
1.
2.
3.
Describe the results you received:
Describe the results you expected:
Provide additional info you think is important:
----------END REPORT ---------
#ENEEDMOREINFO
[-]Why "docker stat " calculation must multiplied by CPU kernal count?[/-][+][BUG REPORT INFORMATION]Why "docker stat " calculation must multiplied by CPU kernal count?[/+]update stats.go
[-][BUG REPORT INFORMATION]Why "docker stat " calculation must multiplied by CPU kernal count?[/-][+]Why "docker stat " calculation must multiplied by CPU kernal count?[/+]coolljt0725 commentedon Jun 1, 2015
I have some comments in #13627 (comment) about this
thaJeztah commentedon Jun 1, 2015
From the comment linked by @coolljt0725;
Agreed; for example, on a 4-core system, cpu usage can be anywhere between 0 and 400%, so it has to be multiplied by the number of cores.
I'm going to close this issue, because I don't think this change is correct, but feel free to comment if you think I closed this by mistake.
Liuyanglong commentedon Jun 9, 2015
@thaJeztah @coolljt0725
We have different opinions on this question.

I think the "stats CPU%" should be the average, but sourcecode says it should be total.
I have a Pic about docker stats run on my server, one of the containers is larger than 100%, so if do not know how many cpu cores on my server, I will never know how much cpu idle left.
coolljt0725 commentedon Jun 9, 2015
@Liuyanglong We can get the cpu cores by using
docker info
, so I don't think this is a problem.Liuyanglong commentedon Jun 9, 2015
@coolljt0725 I do not think this is a problom, but it feel strange .
I want get a number show me the esource usage from '' docker stats", but now I must get the number from 'docker stats' and 'docker info'.For me, I care more about average.