fix(docker): EE-348: fix Docker stats when using cgroups v2 (#5609)

Signed-off-by: Sven Dowideit <sven@mini.home.org.au>
pull/5827/head
Sven Dowideit 3 years ago committed by GitHub
parent 46ffca92fd
commit 9045e17cba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -79,25 +79,42 @@ export function ContainerStatsViewModel(data) {
if (data.memory_stats.stats === undefined || data.memory_stats.usage === undefined) { if (data.memory_stats.stats === undefined || data.memory_stats.usage === undefined) {
this.MemoryUsage = this.MemoryCache = 0; this.MemoryUsage = this.MemoryCache = 0;
} else { } else {
this.MemoryUsage = data.memory_stats.usage - data.memory_stats.stats.cache; this.MemoryCache = 0;
this.MemoryCache = data.memory_stats.stats.cache; if (data.memory_stats.stats.cache !== undefined) {
// cgroups v1
this.MemoryCache = data.memory_stats.stats.cache;
}
this.MemoryUsage = data.memory_stats.usage - this.MemoryCache;
} }
} }
this.PreviousCPUTotalUsage = data.precpu_stats.cpu_usage.total_usage; this.PreviousCPUTotalUsage = data.precpu_stats.cpu_usage.total_usage;
this.PreviousCPUSystemUsage = data.precpu_stats.system_cpu_usage; this.PreviousCPUSystemUsage = data.precpu_stats.system_cpu_usage;
this.CurrentCPUTotalUsage = data.cpu_stats.cpu_usage.total_usage; this.CurrentCPUTotalUsage = data.cpu_stats.cpu_usage.total_usage;
this.CurrentCPUSystemUsage = data.cpu_stats.system_cpu_usage; this.CurrentCPUSystemUsage = data.cpu_stats.system_cpu_usage;
this.CPUCores = 1;
if (data.cpu_stats.cpu_usage.percpu_usage) { if (data.cpu_stats.cpu_usage.percpu_usage) {
this.CPUCores = data.cpu_stats.cpu_usage.percpu_usage.length; this.CPUCores = data.cpu_stats.cpu_usage.percpu_usage.length;
} else {
if (data.cpu_stats.online_cpus !== undefined) {
this.CPUCores = data.cpu_stats.online_cpus;
}
} }
this.Networks = _.values(data.networks); this.Networks = _.values(data.networks);
if (data.blkio_stats !== undefined) { if (data.blkio_stats !== undefined) {
//TODO: take care of multiple block devices //TODO: take care of multiple block devices
var readData = data.blkio_stats.io_service_bytes_recursive.find((d) => d.op === 'Read'); var readData = data.blkio_stats.io_service_bytes_recursive.find((d) => d.op === 'Read');
if (readData === undefined) {
// try the cgroups v2 version
readData = data.blkio_stats.io_service_bytes_recursive.find((d) => d.op === 'read');
}
if (readData !== undefined) { if (readData !== undefined) {
this.BytesRead = readData.value; this.BytesRead = readData.value;
} }
var writeData = data.blkio_stats.io_service_bytes_recursive.find((d) => d.op === 'Write'); var writeData = data.blkio_stats.io_service_bytes_recursive.find((d) => d.op === 'Write');
if (writeData === undefined) {
// try the cgroups v2 version
writeData = data.blkio_stats.io_service_bytes_recursive.find((d) => d.op === 'write');
}
if (writeData !== undefined) { if (writeData !== undefined) {
this.BytesWrite = writeData.value; this.BytesWrite = writeData.value;
} }

Loading…
Cancel
Save