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 AF6941FF16B for ; Tue, 26 Aug 2025 15:51:46 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2D70C34CDE; Tue, 26 Aug 2025 15:51:39 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Date: Tue, 26 Aug 2025 15:51:14 +0200 Message-ID: <20250826135119.336510-20-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250826135119.336510-1-l.wagner@proxmox.com> References: <20250826135119.336510-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1756216281987 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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 proxmox-datacenter-manager v7 19/24] pdm-client: add metric collection API methods 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 adds bindings for collection settings, trigger, and status APIs. Signed-off-by: Lukas Wagner Reviewed-by: Maximiliano Sandoval Reviewed-by: Dominik Csapak Tested-by: Dominik Csapak --- lib/pdm-client/src/lib.rs | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs index 767ac873..f2bb546a 100644 --- a/lib/pdm-client/src/lib.rs +++ b/lib/pdm-client/src/lib.rs @@ -318,6 +318,62 @@ impl PdmClient { .ok_or_else(|| Error::BadApi("api returned no webauthn entry id".to_string(), None)) } + /// Trigger metric collection for a single remote or for all remotes, if no remote is provided. + pub async fn trigger_metric_collection( + &self, + remote: Option<&str>, + ) -> Result<(), proxmox_client::Error> { + let path = "/api2/extjs/metric-collection/trigger"; + + #[derive(Serialize)] + struct TriggerParams<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + remote: Option<&'a str>, + } + + self.0 + .post(path, &TriggerParams { remote }) + .await? + .nodata()?; + + Ok(()) + } + + /// Get global metric collection status. + pub async fn get_metric_collection_status( + &self, + ) -> Result, Error> { + let path = "/api2/extjs/metric-collection/status"; + Ok(self.0.get(path).await?.expect_json()?.data) + } + + /// Get PDM node RRD data. + pub async fn get_pdm_node_rrddata( + &self, + mode: RrdMode, + timeframe: RrdTimeframe, + ) -> Result { + let path = ApiPathBuilder::new("/api2/extjs/nodes/localhost/rrddata") + .arg("cf", mode) + .arg("timeframe", timeframe) + .build(); + Ok(self.0.get(&path).await?.expect_json()?.data) + } + + /// Get per-remote RRD data. + pub async fn get_per_remote_rrddata( + &self, + remote: &str, + mode: RrdMode, + timeframe: RrdTimeframe, + ) -> Result { + let path = ApiPathBuilder::new(format!("/api2/extjs/remotes/{remote}/rrddata")) + .arg("cf", mode) + .arg("timeframe", timeframe) + .build(); + Ok(self.0.get(&path).await?.expect_json()?.data) + } + pub async fn pve_list_nodes( &self, remote: &str, -- 2.47.2 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel