Skip to content

Commit

Permalink
Show cumulative CPU use in pod
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasmatus committed Oct 21, 2024
1 parent 094af5a commit 1a5a9f2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Containers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class Containers extends React.Component {
}

// As podman does not provide per pod memory/cpu statistics we do the following:
// - don't add up CPU usage, instead display the highest found CPU usage of the containers in a pod
// - add up CPU usage to display total CPU use of all containers in the pod
// - add up memory usage so it displays the total memory of the pod.
let cpu = 0;
let mem = 0;
Expand All @@ -505,16 +505,15 @@ class Containers extends React.Component {
continue;

if (containerStats.CPU != undefined) {
const val = containerStats.CPU === 0 ? containerStats.CPU : containerStats.CPU.toFixed(2);
if (val > cpu)
cpu = val;
cpu += containerStats.CPU;
}
if (containerStats.MemUsage != undefined)
if (containerStats.MemUsage != undefined) {
mem += containerStats.MemUsage;
}
}

return {
cpu,
cpu: cpu.toFixed(2),
mem,
};
}
Expand Down

0 comments on commit 1a5a9f2

Please sign in to comment.