fix the bug: cpu percent will extremely high
| ... | ... |
@@ -317,9 +317,9 @@ func calculateCPUPercent(previousCPU, previousSystem uint64, v *types.StatsJSON) |
| 317 | 317 |
var ( |
| 318 | 318 |
cpuPercent = 0.0 |
| 319 | 319 |
// calculate the change for the cpu usage of the container in between readings |
| 320 |
- cpuDelta = float64(v.CPUStats.CPUUsage.TotalUsage - previousCPU) |
|
| 320 |
+ cpuDelta = float64(v.CPUStats.CPUUsage.TotalUsage) - float64(previousCPU) |
|
| 321 | 321 |
// calculate the change for the entire system between readings |
| 322 |
- systemDelta = float64(v.CPUStats.SystemUsage - previousSystem) |
|
| 322 |
+ systemDelta = float64(v.CPUStats.SystemUsage) - float64(previousSystem) |
|
| 323 | 323 |
) |
| 324 | 324 |
|
| 325 | 325 |
if systemDelta > 0.0 && cpuDelta > 0.0 {
|