A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
fix(docker): stats not working (#4311)
Meier Lukas9aa2d5ccd8cf
diff --git a/packages/request-handler/src/docker.ts b/packages/request-handler/src/docker.tsindex 3e30aa1a6..cd82688d3 100644--- a/packages/request-handler/src/docker.ts+++ b/packages/request-handler/src/docker.ts@@ -61,7 +61,17 @@ async function getContainersWithStatsAsync() {})?.url ?? null,cpuUsage: calculateCpuUsage(stats),// memory usage by default includes cache, which should not be shown as it is also not shown with docker stats command- memoryUsage: stats.memory_stats.usage - stats.memory_stats.stats.cache,+ // The below type is probably wrong, sometimes stats can be undefined+ // See https://docs.docker.com/reference/cli/docker/container/stats/ how it is / was calculated+ memoryUsage:+ stats.memory_stats.usage -+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition+ (stats.memory_stats.stats?.cache ??+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition+ stats.memory_stats.stats?.total_inactive_file ??+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition+ stats.memory_stats.stats?.inactive_file ??+ 0),image: container.Image,ports: container.Ports,};@@ -71,11 +81,10 @@ async function getContainersWithStatsAsync() {}function calculateCpuUsage(stats: ContainerStats): number {- const cpuDelta = stats.cpu_stats.cpu_usage.total_usage - stats.precpu_stats.cpu_usage.total_usage;- const systemDelta = stats.cpu_stats.system_cpu_usage - stats.precpu_stats.system_cpu_usage;const numberOfCpus = stats.cpu_stats.online_cpus || 1;- if (systemDelta === 0) return 0;+ const usage = stats.cpu_stats.system_cpu_usage;+ if (usage === 0) return 0;- return (cpuDelta / systemDelta) * numberOfCpus * 100;+ return (stats.cpu_stats.cpu_usage.total_usage / usage) * numberOfCpus * 100;}