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 AFC531FF13F for ; Thu, 12 Mar 2026 14:53:40 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DB31617B80; Thu, 12 Mar 2026 14:53:28 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 24/26] pdm-api-types: add PDM host metric fields Date: Thu, 12 Mar 2026 14:52:25 +0100 Message-ID: <20260312135229.420729-25-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260312135229.420729-1-l.wagner@proxmox.com> References: <20260312135229.420729-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773323525114 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.047 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_MSPIKE_H2 0.001 Average reputation (+2) 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: GONCRJYZXSHULNOUOACJLSOH7QGXJMNF X-Message-ID-Hash: GONCRJYZXSHULNOUOACJLSOH7QGXJMNF 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: Signed-off-by: Lukas Wagner --- lib/pdm-api-types/src/rrddata.rs | 72 +++++++++++++++++++++++++++++++- server/src/api/nodes/rrddata.rs | 55 ++++++++++++++++++++++-- 2 files changed, 122 insertions(+), 5 deletions(-) diff --git a/lib/pdm-api-types/src/rrddata.rs b/lib/pdm-api-types/src/rrddata.rs index 6eaaff3c..452597a8 100644 --- a/lib/pdm-api-types/src/rrddata.rs +++ b/lib/pdm-api-types/src/rrddata.rs @@ -233,13 +233,81 @@ pub struct PbsDatastoreDataPoint { } #[api] -#[derive(Serialize, Deserialize, Default)] +#[derive(Serialize, Deserialize, Default, Debug)] #[serde(rename_all = "kebab-case")] /// RRD datapoint for statistics about the metric collection loop. pub struct PdmNodeDatapoint { /// Timestamp (UNIX epoch) pub time: u64, - + /// Current CPU utilization + #[serde(skip_serializing_if = "Option::is_none")] + pub cpu_current: Option, + /// Current IO wait + #[serde(skip_serializing_if = "Option::is_none")] + pub cpu_iowait: Option, + /// CPU utilization, averaged over the last minute + #[serde(skip_serializing_if = "Option::is_none")] + pub cpu_avg1: Option, + /// CPU utilization, averaged over the last five minutes + #[serde(skip_serializing_if = "Option::is_none")] + pub cpu_avg5: Option, + /// CPU utilization, averaged over the last fifteen minutes + #[serde(skip_serializing_if = "Option::is_none")] + pub cpu_avg15: Option, + /// Total root disk size + #[serde(skip_serializing_if = "Option::is_none")] + pub disk_total: Option, + /// Total root disk usage + #[serde(skip_serializing_if = "Option::is_none")] + pub disk_used: Option, + /// Root disk read IOPS + #[serde(skip_serializing_if = "Option::is_none")] + pub disk_read_iops: Option, + /// Root disk write IOPS + #[serde(skip_serializing_if = "Option::is_none")] + pub disk_write_iops: Option, + /// Root disk read rate + #[serde(skip_serializing_if = "Option::is_none")] + pub disk_read: Option, + /// Root disk write rate + #[serde(skip_serializing_if = "Option::is_none")] + pub disk_write: Option, + /// Root disk IO ticks + #[serde(skip_serializing_if = "Option::is_none")] + pub disk_io_ticks: Option, + /// Total memory size + #[serde(skip_serializing_if = "Option::is_none")] + pub mem_total: Option, + /// Currently used memory + #[serde(skip_serializing_if = "Option::is_none")] + pub mem_used: Option, + /// Total swap size + #[serde(skip_serializing_if = "Option::is_none")] + pub swap_total: Option, + /// Current swap usage + #[serde(skip_serializing_if = "Option::is_none")] + pub swap_used: Option, + /// Inbound network data rate + #[serde(skip_serializing_if = "Option::is_none")] + pub net_in: Option, + /// Outbound network data rate + #[serde(skip_serializing_if = "Option::is_none")] + pub net_out: Option, + /// Average 'some' CPU pressure over the last 10 minutes. + #[serde(skip_serializing_if = "Option::is_none")] + pub cpu_pressure_some_avg10: Option, + /// Average 'some' memory pressure over the last 10 minutes. + #[serde(skip_serializing_if = "Option::is_none")] + pub mem_pressure_some_avg10: Option, + /// Average 'full' memory pressure over the last 10 minutes. + #[serde(skip_serializing_if = "Option::is_none")] + pub mem_pressure_full_avg10: Option, + /// Average 'some' IO pressure over the last 10 minutes. + #[serde(skip_serializing_if = "Option::is_none")] + pub io_pressure_some_avg10: Option, + /// Average 'full' IO pressure over the last 10 minutes. + #[serde(skip_serializing_if = "Option::is_none")] + pub io_pressure_full_avg10: Option, /// Total time in milliseconds needed for full metric collection run. #[serde(skip_serializing_if = "Option::is_none")] pub metric_collection_total_time: Option, diff --git a/server/src/api/nodes/rrddata.rs b/server/src/api/nodes/rrddata.rs index 00c4eee0..8ba11a5f 100644 --- a/server/src/api/nodes/rrddata.rs +++ b/server/src/api/nodes/rrddata.rs @@ -18,12 +18,61 @@ impl DataPoint for PdmNodeDatapoint { } fn fields() -> &'static [&'static str] { - &["metric-collection-total-time"] + &[ + "cpu-current", + "cpu-iowait", + "cpu-avg1", + "cpu-avg5", + "cpu-avg15", + "cpu-pressure-some-avg10", + "disk-total", + "disk-used", + "disk-read-iops", + "disk-write-iops", + "disk-read", + "disk-write", + "disk-io-ticks", + "io-pressure-some-avg10", + "io-pressure-full-avg10", + "mem-total", + "mem-used", + "mem-pressure-some-avg10", + "mem-pressure-full-avg10", + "swap-total", + "swap-used", + "net-in", + "net-out", + "metric-collection-total-time", + ] } fn set_field(&mut self, name: &str, value: f64) { - if name == "metric-collection-total-time" { - self.metric_collection_total_time = Some(value); + match name { + "cpu-current" => self.cpu_current = Some(value), + "cpu-iowait" => self.cpu_iowait = Some(value), + "cpu-avg1" => self.cpu_avg1 = Some(value), + "cpu-avg5" => self.cpu_avg5 = Some(value), + "cpu-avg15" => self.cpu_avg15 = Some(value), + "cpu-pressure-some-avg10" => self.cpu_pressure_some_avg10 = Some(value), + "disk-total" => self.disk_total = Some(value), + "disk-used" => self.disk_used = Some(value), + "disk-read-iops" => self.disk_read_iops = Some(value), + "disk-write-iops" => self.disk_write_iops = Some(value), + "disk-read" => self.disk_read = Some(value), + "disk-write" => self.disk_write = Some(value), + "disk-io-ticks" => self.disk_io_ticks = Some(value), + "io-pressure-some-avg10" => self.io_pressure_some_avg10 = Some(value), + "io-pressure-full-avg10" => self.io_pressure_full_avg10 = Some(value), + "mem-total" => self.mem_total = Some(value), + "mem-used" => self.mem_used = Some(value), + "mem-pressure-some-avg10" => self.mem_pressure_some_avg10 = Some(value), + "mem-pressure-full-avg10" => self.mem_pressure_full_avg10 = Some(value), + "swap-total" => self.swap_total = Some(value), + "swap-used" => self.swap_used = Some(value), + "net-in" => self.net_in = Some(value), + "net-out" => self.net_out = Some(value), + "metric-collection-total-time" => self.metric_collection_total_time = Some(value), + _ => log::error!("setting invalid field '{name}' in PdmNodeDatapoint"), } } } -- 2.47.3