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 B08B21FF13C for ; Thu, 02 Apr 2026 15:02:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3ED10192D3; Thu, 2 Apr 2026 15:02:52 +0200 (CEST) Message-ID: <1fc88a7c-1b5d-4426-bf18-6a1b3d245e66@proxmox.com> Date: Thu, 2 Apr 2026 15:02:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH datacenter-manager v2 1/4] api: return global cpu/memory/storage statistics To: Lukas Wagner , pdm-devel@lists.proxmox.com References: <20260330131044.693709-1-d.csapak@proxmox.com> <20260330131044.693709-2-d.csapak@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775134876282 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.453 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: H3G7CINCY2TC6TGJCPEXACJHM54OEROC X-Message-ID-Hash: H3G7CINCY2TC6TGJCPEXACJHM54OEROC X-MailFrom: d.csapak@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: On 4/1/26 1:33 PM, Lukas Wagner wrote: > 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 = 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). >> @@ -202,6 +202,18 @@ pub struct StorageStatus { >> pub avail: u64, >> } >> >> +#[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 = StringSchema::new("Password hint.") >> .format(&SINGLE_LINE_COMMENT_FORMAT) >> .min_length(1) >> diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.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, OneOfSchema, Schema, StringSchema}; >> >> use super::remotes::{RemoteType, REMOTE_ID_SCHEMA}; >> +use super::{MemoryStatus, StorageStatus}; >> + >> use pve_api_types::ClusterResourceNetworkType; >> >> /// High PBS datastore usage threshold >> @@ -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 > > 'thread' is a countable noun, so it should rather be "Number of threads" thanks, i'll fix it, but just to note, in that same file we have many instances of this, for example: "Amount of running guests" "Amount of online datastores" "Amount of configured remotes" which all seem to me like countable nouns? so we might want to clean that up for all of them > >> + 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, >> +} >> + >