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 BDD601FF170 for ; Thu, 21 Aug 2025 11:53:55 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 655C51C73C; Thu, 21 Aug 2025 11:53:52 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Date: Thu, 21 Aug 2025 11:53:11 +0200 Message-ID: <20250821095319.134215-16-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250821095319.134215-1-l.wagner@proxmox.com> References: <20250821095319.134215-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1755769977562 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.126 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 POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes 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 proxmox-datacenter-manager v6 15/23] api: add endpoint to trigger metric collection 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" This one lives under /metric-collection/trigger. Doing a POST will trigger metric collection for a remote provided in the 'remote' parameter, or all remotes if the parameter is not provided. Signed-off-by: Lukas Wagner Reviewed-by: Maximiliano Sandoval --- server/src/api/metric_collection.rs | 35 +++++++++++++++++++++++++++++ server/src/api/mod.rs | 2 ++ 2 files changed, 37 insertions(+) create mode 100644 server/src/api/metric_collection.rs diff --git a/server/src/api/metric_collection.rs b/server/src/api/metric_collection.rs new file mode 100644 index 00000000..1a9e0e28 --- /dev/null +++ b/server/src/api/metric_collection.rs @@ -0,0 +1,35 @@ +use anyhow::Error; + +use pdm_api_types::remotes::REMOTE_ID_SCHEMA; +use proxmox_router::{Router, SubdirMap}; +use proxmox_schema::api; +use proxmox_sortable_macro::sortable; + +pub const ROUTER: Router = Router::new().subdirs(SUBDIRS); + +#[sortable] +const SUBDIRS: SubdirMap = &sorted!([( + "trigger", + &Router::new().post(&API_METHOD_TRIGGER_METRIC_COLLECTION) +),]); + +#[api( + input: { + properties: { + remote: { + schema: REMOTE_ID_SCHEMA, + optional: true, + }, + }, + }, +)] +/// Trigger metric collection for a provided remote or for all remotes if no remote is passed. +pub async fn trigger_metric_collection(remote: Option) -> Result<(), Error> { + if let Some(remote) = remote { + crate::metric_collection::trigger_metric_collection_for_remote(remote).await?; + } else { + crate::metric_collection::trigger_metric_collection().await?; + } + + Ok(()) +} diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index 6c4831b4..ff875fc8 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -9,6 +9,7 @@ use proxmox_sortable_macro::sortable; pub mod access; pub mod config; +pub mod metric_collection; pub mod nodes; pub mod pbs; pub mod pve; @@ -21,6 +22,7 @@ mod rrd_common; const SUBDIRS: SubdirMap = &sorted!([ ("access", &access::ROUTER), ("config", &config::ROUTER), + ("metric-collection", &metric_collection::ROUTER), ("ping", &Router::new().get(&API_METHOD_PING)), ("pve", &pve::ROUTER), ("pbs", &pbs::ROUTER), -- 2.47.2 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel