(previousCPU container.CPUStats, curCPUStats container.CPUStats)
| 181 | } |
| 182 | |
| 183 | func calculateCPUPercentUnix(previousCPU container.CPUStats, curCPUStats container.CPUStats) float64 { |
| 184 | var ( |
| 185 | cpuPercent = 0.0 |
| 186 | // calculate the change for the cpu usage of the container in between readings |
| 187 | cpuDelta = float64(curCPUStats.CPUUsage.TotalUsage) - float64(previousCPU.CPUUsage.TotalUsage) |
| 188 | // calculate the change for the entire system between readings |
| 189 | systemDelta = float64(curCPUStats.SystemUsage) - float64(previousCPU.SystemUsage) |
| 190 | onlineCPUs = float64(curCPUStats.OnlineCPUs) |
| 191 | ) |
| 192 | |
| 193 | if onlineCPUs == 0.0 { |
| 194 | onlineCPUs = float64(len(curCPUStats.CPUUsage.PercpuUsage)) |
| 195 | } |
| 196 | if systemDelta > 0.0 && cpuDelta > 0.0 { |
| 197 | cpuPercent = (cpuDelta / systemDelta) * onlineCPUs * 100.0 |
| 198 | } |
| 199 | return cpuPercent |
| 200 | } |
| 201 | |
| 202 | func calculateCPUPercentWindows(v *container.StatsResponse) float64 { |
| 203 | // Max number of 100ns intervals between the previous time read and now |
no outgoing calls
no test coverage detected
searching dependent graphs…