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 8C0B71FF137 for ; Tue, 17 Feb 2026 15:13:54 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F10AF1D8C; Tue, 17 Feb 2026 15:14:45 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [RFC proxmox 3/5] resource-scheduling: add dynamic node and service stats Date: Tue, 17 Feb 2026 15:13:57 +0100 Message-ID: <20260217141437.584852-4-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260217141437.584852-1-d.kral@proxmox.com> References: <20260217141437.584852-1-d.kral@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1771337676091 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.019 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 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: PARC4D2B2WVRAPMLHAFJEKZJUQHG7357 X-Message-ID-Hash: PARC4D2B2WVRAPMLHAFJEKZJUQHG7357 X-MailFrom: d.kral@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 VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Daniel Kral --- proxmox-resource-scheduling/src/lib.rs | 1 + .../src/pve_dynamic.rs | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 proxmox-resource-scheduling/src/pve_dynamic.rs diff --git a/proxmox-resource-scheduling/src/lib.rs b/proxmox-resource-scheduling/src/lib.rs index c73e7b1e..2c22dbce 100644 --- a/proxmox-resource-scheduling/src/lib.rs +++ b/proxmox-resource-scheduling/src/lib.rs @@ -3,4 +3,5 @@ pub mod topsis; pub mod scheduler; +pub mod pve_dynamic; pub mod pve_static; diff --git a/proxmox-resource-scheduling/src/pve_dynamic.rs b/proxmox-resource-scheduling/src/pve_dynamic.rs new file mode 100644 index 00000000..4f480612 --- /dev/null +++ b/proxmox-resource-scheduling/src/pve_dynamic.rs @@ -0,0 +1,53 @@ +use serde::{Deserialize, Serialize}; + +use crate::scheduler::{NodeStats, ServiceStats}; + +#[derive(Clone, Copy, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +/// Dynamic usage stats of a node. +pub struct DynamicNodeStats { + /// CPU utilization in CPU cores. + pub cpu: f64, + /// Total number of CPU cores. + pub maxcpu: usize, + /// Used memory in bytes. + pub mem: usize, + /// Total memory in bytes. + pub maxmem: usize, +} + +impl From for NodeStats { + fn from(value: DynamicNodeStats) -> Self { + Self { + cpu: value.cpu, + maxcpu: value.maxcpu, + mem: value.mem, + maxmem: value.maxmem, + } + } +} + +#[derive(Clone, Copy, Default, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +/// Dynamic usage stats of an HA resource. +pub struct DynamicServiceStats { + /// CPU utilization in CPU cores. + pub cpu: f64, + /// Number of assigned CPUs or CPU limit. + pub maxcpu: f64, + /// Used memory in bytes. + pub mem: usize, + /// Maximum assigned memory in bytes. + pub maxmem: usize, +} + +impl From for ServiceStats { + fn from(value: DynamicServiceStats) -> Self { + Self { + cpu: value.cpu, + maxcpu: value.maxcpu, + mem: value.mem, + maxmem: value.maxmem, + } + } +} -- 2.47.3