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 756C61FF187 for ; Mon, 8 Sep 2025 16:05:09 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2A15313BE3; Mon, 8 Sep 2025 16:05:12 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Mon, 8 Sep 2025 16:04:14 +0200 Message-ID: <20250908140424.3376082-8-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250908140424.3376082-1-d.csapak@proxmox.com> References: <20250908140424.3376082-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.023 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 Subject: [pdm-devel] [PATCH datacenter-manager 3/7] server: api: add rrddata endpoint for pve storages X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" Signed-off-by: Dominik Csapak --- server/src/api/pve/rrddata.rs | 57 +++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/server/src/api/pve/rrddata.rs b/server/src/api/pve/rrddata.rs index b6a0403..e08d4b4 100644 --- a/server/src/api/pve/rrddata.rs +++ b/server/src/api/pve/rrddata.rs @@ -8,8 +8,8 @@ use proxmox_rrd_api_types::{RrdMode, RrdTimeframe}; use proxmox_schema::api; use pdm_api_types::remotes::REMOTE_ID_SCHEMA; -use pdm_api_types::rrddata::{LxcDataPoint, NodeDataPoint, QemuDataPoint}; -use pdm_api_types::{NODE_SCHEMA, PRIV_RESOURCE_AUDIT, VMID_SCHEMA}; +use pdm_api_types::rrddata::{LxcDataPoint, NodeDataPoint, PveStorageDataPoint, QemuDataPoint}; +use pdm_api_types::{NODE_SCHEMA, PRIV_RESOURCE_AUDIT, PVE_STORAGE_ID_SCHEMA, VMID_SCHEMA}; use crate::api::rrd_common::{self, DataPoint}; use crate::metric_collection; @@ -146,6 +146,27 @@ impl DataPoint for LxcDataPoint { } } +impl DataPoint for PveStorageDataPoint { + fn new(time: u64) -> Self { + Self { + time, + ..Default::default() + } + } + + fn fields() -> &'static [&'static str] { + &["disk_total", "disk_used"] + } + + fn set_field(&mut self, name: &str, value: f64) { + match name { + "disk_total" => self.disk_total = Some(value), + "disk_used" => self.disk_used = Some(value), + _ => {} + } + } +} + #[api( input: { properties: { @@ -233,6 +254,37 @@ async fn get_node_rrd_data( get_rrd_datapoints(remote, base, timeframe, cf).await } +#[api( + input: { + properties: { + remote: { schema: REMOTE_ID_SCHEMA }, + node: { schema: NODE_SCHEMA }, + storage: { schema: PVE_STORAGE_ID_SCHEMA }, + timeframe: { + type: RrdTimeframe, + }, + cf: { + type: RrdMode, + }, + }, + }, + access: { + permission: &Permission::Privilege(&["resource", "{remote}", "storage", "{storage}"], PRIV_RESOURCE_AUDIT, false), + }, +)] +/// Read node stats +async fn get_storage_rrd_data( + remote: String, + node: String, + storage: String, + timeframe: RrdTimeframe, + cf: RrdMode, + _param: Value, +) -> Result, Error> { + let base = format!("pve/{remote}/storage/{node}/{storage}"); + get_rrd_datapoints(remote, base, timeframe, cf).await +} + async fn get_rrd_datapoints( remote: String, basepath: String, @@ -260,3 +312,4 @@ async fn get_rrd_datapoints( pub const QEMU_RRD_ROUTER: Router = Router::new().get(&API_METHOD_GET_QEMU_RRD_DATA); pub const LXC_RRD_ROUTER: Router = Router::new().get(&API_METHOD_GET_LXC_RRD_DATA); pub const NODE_RRD_ROUTER: Router = Router::new().get(&API_METHOD_GET_NODE_RRD_DATA); +pub const STORAGE_RRD_ROUTER: Router = Router::new().get(&API_METHOD_GET_STORAGE_RRD_DATA); -- 2.47.2 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel