From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 5D6BA1FF13B for ; Wed, 25 Mar 2026 17:49:19 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4CD6F31340; Wed, 25 Mar 2026 17:49:40 +0100 (CET) Message-ID: <349c4dde-549c-4a06-a20b-094b6a4cad78@proxmox.com> Date: Wed, 25 Mar 2026 17:49:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH datacenter-manager 1/4] api: return global cpu/memory/storage statistics To: Dominik Csapak , pdm-devel@lists.proxmox.com References: <20260323110728.1500528-1-d.csapak@proxmox.com> <20260323110728.1500528-2-d.csapak@proxmox.com> Content-Language: en-US From: Thomas Lamprecht In-Reply-To: <20260323110728.1500528-2-d.csapak@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774457328397 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.011 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 0.001 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 0.001 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 0.001 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: DJ3RNDOFSGGZVDPQ44GLD7UD32IKEUTX X-Message-ID-Hash: DJ3RNDOFSGGZVDPQ44GLD7UD32IKEUTX X-MailFrom: t.lamprecht@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: Am 23.03.26 um 12:06 schrieb Dominik Csapak: > 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 | 2 +- > lib/pdm-api-types/src/resource.rs | 27 +++++++++++++ > server/src/api/resources.rs | 65 ++++++++++++++++++++++++------- > 3 files changed, 80 insertions(+), 14 deletions(-) > > diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs > index d4cc7ef0..9bccd50f 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 = StringSchema::new("Storage ID.") > // Complex type definitions > > #[api()] > -#[derive(Default, Serialize, Deserialize)] > +#[derive(Default, Serialize, Deserialize, PartialEq, Clone)] > /// Storage space usage information. > pub struct StorageStatus { > /// Total space (bytes). > diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs > index d2db3b5a..1f74e09c 100644 > --- a/lib/pdm-api-types/src/resource.rs > +++ b/lib/pdm-api-types/src/resource.rs > @@ -666,6 +668,18 @@ pub struct SdnZoneCount { > pub unknown: u64, > } > > +#[api] > +#[derive(Default, Serialize, Deserialize, Clone, PartialEq)] > +/// Statistics for CPU utilization > +pub struct CpuStatistics { > + /// Amount of threads utilized > + pub used: f64, > + /// Amount of physically available cpu threads > + pub max: f64, > + /// Currently allocated cores of running guests (only on PVE) > + pub allocated: Option, > +} > + > #[api( > properties: { > "failed_remotes_list": { > @@ -697,6 +711,19 @@ pub struct ResourcesStatus { > pub pbs_nodes: NodeStatusCount, > /// Status of PBS Datastores > pub pbs_datastores: PbsDatastoreStatusCount, > + /// Combined CPU statistics for all PVE remotes > + pub pve_cpu_stats: CpuStatistics, > + /// Combined CPU statistics for all PBS remotes > + pub pbs_cpu_stats: CpuStatistics, > + /// Combined Memory statistics for all PVE remotes > + pub pve_memory_stats: StorageStatus, > + /// Combined Memory statistics for all PBS remotes > + pub pbs_memory_stats: StorageStatus, should above two memory fields also use a type named MemoryStatus or the like, or is this reused because the fields are basically the same anyway? A type alias might still make sense to have in the latter case for more clarity that this is on purpose and nothing against dedicated types even if they got the same fields, as they refer to different things nonetheless, as e.g. a hypothetical Display impl would likely differ (IEC vs SI units). > + /// Combined Storage statistics for all PVE remotes (shared storages are only counted once per > + /// remote). > + pub pve_storage_stats: StorageStatus, > + /// Combined Storage statistics for all PBS remotes > + pub pbs_storage_stats: StorageStatus, > /// List of the failed remotes including type and error > #[serde(default, skip_serializing_if = "Vec::is_empty")] > pub failed_remotes_list: Vec,