check for length of perusage for stat gathering and removed not used function (#9009)

This commit is contained in:
Aladex 2021-03-22 22:01:25 +03:00 committed by GitHub
parent 74a1acd814
commit dc8e4ef62e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -732,7 +732,7 @@ func parseContainerStats(
acc.AddFields("docker_container_cpu", cpufields, cputags, tm)
}
if choice.Contains("cpu", perDeviceInclude) {
if choice.Contains("cpu", perDeviceInclude) && len(stat.CPUStats.CPUUsage.PercpuUsage) > 0 {
// If we have OnlineCPUs field, then use it to restrict stats gathering to only Online CPUs
// (https://github.com/moby/moby/commit/115f91d7575d6de6c7781a96a082f144fd17e400)
var percpuusage []uint64