From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 7CBAE1FF13A for ; Wed, 01 Apr 2026 13:34:14 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6566E18A7E; Wed, 1 Apr 2026 13:34:42 +0200 (CEST) Content-Type: text/plain; charset=UTF-8 Date: Wed, 01 Apr 2026 13:34:38 +0200 Message-Id: Subject: Re: [PATCH datacenter-manager v2 1/4] api: return global cpu/memory/storage statistics From: "Lukas Wagner" To: "Dominik Csapak" , Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: aerc 0.21.0-0-g5549850facc2-dirty References: <20260330131044.693709-1-d.csapak@proxmox.com> <20260330131044.693709-2-d.csapak@proxmox.com> In-Reply-To: <20260330131044.693709-2-d.csapak@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775043221278 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.449 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: Z272C7WGWFVU4GZHQTS5BMLACXYMC72M X-Message-ID-Hash: Z272C7WGWFVU4GZHQTS5BMLACXYMC72M X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Looking good, some tiny suggestions for improvement inline. Can also be fixed in a small follow-up patch in case there is nothing else that needs to be changed. On Mon Mar 30, 2026 at 3:07 PM CEST, Dominik Csapak wrote: > Global CPU/memory/storage usage (per remote type) is useful and > interesting from an administration POV. Calculate and return these so > we can use them on the dashboards. > > Signed-off-by: Dominik Csapak > --- > lib/pdm-api-types/src/lib.rs | 14 ++++++- > lib/pdm-api-types/src/resource.rs | 27 +++++++++++++ > server/src/api/resources.rs | 65 ++++++++++++++++++++++++------- > 3 files changed, 92 insertions(+), 14 deletions(-) > > diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs > index d4cc7ef0..28aed3f4 100644 > --- a/lib/pdm-api-types/src/lib.rs > +++ b/lib/pdm-api-types/src/lib.rs > @@ -191,7 +191,7 @@ pub const PVE_STORAGE_ID_SCHEMA: Schema =3D StringSch= ema::new("Storage ID.") > // Complex type definitions > =20 > #[api()] > -#[derive(Default, Serialize, Deserialize)] > +#[derive(Default, Serialize, Deserialize, PartialEq, Clone)] > /// Storage space usage information. > pub struct StorageStatus { > /// Total space (bytes). > @@ -202,6 +202,18 @@ pub struct StorageStatus { > pub avail: u64, > } > =20 > +#[api()] nit: you can leave out the parentheses: #[api] > +#[derive(Default, Serialize, Deserialize, PartialEq, Clone)] > +/// Storage space usage information. ^ The doc comment seems to be wrong (copy/paste mistake?) > +pub struct MemoryStatus { > + /// Total memory size (bytes). > + pub total: u64, > + /// Used memory (bytes). > + pub used: u64, > + /// Available memory (bytes). > + pub avail: u64, > +} > + > pub const PASSWORD_HINT_SCHEMA: Schema =3D StringSchema::new("Password h= int.") > .format(&SINGLE_LINE_COMMENT_FORMAT) > .min_length(1) > diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/re= source.rs > index d2db3b5a..01a5eb6c 100644 > --- a/lib/pdm-api-types/src/resource.rs > +++ b/lib/pdm-api-types/src/resource.rs > @@ -6,6 +6,8 @@ use serde::{Deserialize, Serialize}; > use proxmox_schema::{api, ApiStringFormat, ApiType, EnumEntry, OneOfSche= ma, Schema, StringSchema}; > =20 > use super::remotes::{RemoteType, REMOTE_ID_SCHEMA}; > +use super::{MemoryStatus, StorageStatus}; > + > use pve_api_types::ClusterResourceNetworkType; > =20 > /// High PBS datastore usage threshold > @@ -666,6 +668,18 @@ pub struct SdnZoneCount { > pub unknown: u64, > } > =20 > +#[api] > +#[derive(Default, Serialize, Deserialize, Clone, PartialEq)] > +/// Statistics for CPU utilization > +pub struct CpuStatistics { > + /// Amount of threads utilized 'thread' is a countable noun, so it should rather be "Number of threads" > + pub used: f64, > + /// Amount of physically available cpu threads same here > + pub max: f64, > + /// Currently allocated cores of running guests (only on PVE) > + pub allocated: Option, > +} > +