public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Rusovac <d.rusovac@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH yew-mobile-gui v2 2/3] fix #7330: dashboard: display CPU utilization correctly
Date: Thu, 19 Feb 2026 13:05:34 +0100	[thread overview]
Message-ID: <20260219120535.209549-3-d.rusovac@proxmox.com> (raw)
In-Reply-To: <20260219120535.209549-1-d.rusovac@proxmox.com>

This displays CPU utilization across all nodes like "Summary" of
"Resources" in "Datacenter" of PVE web ui.

Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---

 changes since v1:
 * sum up products of cpu and maxcpu per node; and divide by total maxcpu

 src/pages/page_dashboard.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/pages/page_dashboard.rs b/src/pages/page_dashboard.rs
index f637c63..ac8e3e7 100644
--- a/src/pages/page_dashboard.rs
+++ b/src/pages/page_dashboard.rs
@@ -100,7 +100,7 @@ impl PvePageDashboard {
 
                 for node in node_list.iter() {
                     if let (Some(node_cpu), Some(node_maxcpu)) = (node.cpu, node.maxcpu) {
-                        cpu += node_cpu;
+                        cpu += node_cpu * node_maxcpu as f64;
                         maxcpu += node_maxcpu;
                     }
                     if let (Some(node_mem), Some(node_maxmem)) = (node.mem, node.maxmem) {
@@ -109,7 +109,7 @@ impl PvePageDashboard {
                     }
                 }
 
-                let cpu_percentage = if maxcpu == 0 {
+                let cpu_proportion = if maxcpu == 0 {
                     0.0
                 } else {
                     (cpu as f32) / (maxcpu as f32)
@@ -125,9 +125,9 @@ impl PvePageDashboard {
 
                 tiles.push(
                     icon_list_tile(Fa::new("cpu"), tr!("CPU"), (), ()).with_child(list_tile_usage(
-                        format!("{:.2}", cpu),
+                        format!("{:.2}", cpu_proportion * 100.0),
                         maxcpu.to_string(),
-                        cpu_percentage,
+                        cpu_proportion,
                     )),
                 );
 
-- 
2.47.3





  parent reply	other threads:[~2026-02-19 12:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19 12:05 [PATCH yew-mobile-gui v2 0/3] " Dominik Rusovac
2026-02-19 12:05 ` [PATCH yew-mobile-gui v2 1/3] run cargo fmt Dominik Rusovac
2026-02-19 12:05 ` Dominik Rusovac [this message]
2026-02-19 12:05 ` [PATCH yew-mobile-gui v2 3/3] dashboard: clarify presentation of CPU utilization Dominik Rusovac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260219120535.209549-3-d.rusovac@proxmox.com \
    --to=d.rusovac@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal