On 2/18/26 12:04 PM, Dominik Rusovac wrote:
The CPU utilization was displayed incorrectly, because the cached CPU
utilization was mistaken to be the number of utilized CPUs. Instead the
cached CPU utilization is the proportion of utilized CPUs. This handles
the presentation of CPU utilization accordingly.
Signed-off-by: Dominik Rusovac <[email protected]>
---
src/pages/page_dashboard.rs | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/pages/page_dashboard.rs b/src/pages/page_dashboard.rs
index f637c63..93e0f83 100644
--- a/src/pages/page_dashboard.rs
+++ b/src/pages/page_dashboard.rs
@@ -109,11 +109,7 @@ impl PvePageDashboard {
}
}
- let cpu_percentage = if maxcpu == 0 {
- 0.0
- } else {
- (cpu as f32) / (maxcpu as f32)
- };
+ let cpu_percentage = cpu * 100.0;
this looks wrong.
'cpu' is the sum of the whole cpu percentages per node, so in a 4 node
cluster this is a value between 0 and 4, so in your case it would try to
show 400% if all cpus of that cluster were fully loaded ;)
i think a better way to calculate/show that would be to
sum up the 'per core' utilization by summing up like this:
'cpu += (node.cpu * node.maxcpu)'
and then trying to divide by the sum of all 'maxcpus' again like it
was done previously
after that multiplying by 100 and showing it as a percentage
Note that the current code also don't really makes sense, since
it would only be correct if each node would only have one core
let mem_percentage = if maxmem <= 0.0 {
0.0
@@ -125,9 +121,9 @@ impl PvePageDashboard {
tiles.push(
icon_list_tile(Fa::new("cpu"), tr!("CPU"), (),
()).with_child(list_tile_usage(
- format!("{:.2}", cpu),
+ format!("{cpu_percentage:.2}%"),
maxcpu.to_string(),
- cpu_percentage,
+ cpu as f32,
)),
);