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 3826E1FF166 for ; Fri, 11 Oct 2024 12:51:23 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B93983BA9B; Fri, 11 Oct 2024 12:51:46 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com Date: Fri, 11 Oct 2024 12:51:33 +0200 Message-Id: <20241011105137.131530-10-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241011105137.131530-1-l.wagner@proxmox.com> References: <20241011105137.131530-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.008 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: [pbs-devel] [PATCH proxmox-backup 09/13] metric collection: move impl block for DiskStats to metric_server module X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" It is only needed there and could be considered an implementation detail of how this module works. No functional changes intended. Signed-off-by: Lukas Wagner --- src/server/metric_collection/metric_server.rs | 20 ++++++++++++++++++ src/server/metric_collection/mod.rs | 21 ------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/server/metric_collection/metric_server.rs b/src/server/metric_collection/metric_server.rs index cc9f736a..ba20628a 100644 --- a/src/server/metric_collection/metric_server.rs +++ b/src/server/metric_collection/metric_server.rs @@ -134,3 +134,23 @@ fn get_metric_server_connections( } Ok(res) } + +impl DiskStat { + fn to_value(&self) -> Value { + let mut value = json!({}); + if let Some(usage) = &self.usage { + value["total"] = Value::from(usage.total); + value["used"] = Value::from(usage.used); + value["avail"] = Value::from(usage.available); + } + + if let Some(dev) = &self.dev { + value["read_ios"] = Value::from(dev.read_ios); + value["read_bytes"] = Value::from(dev.read_sectors * 512); + value["write_ios"] = Value::from(dev.write_ios); + value["write_bytes"] = Value::from(dev.write_sectors * 512); + value["io_ticks"] = Value::from(dev.io_ticks / 1000); + } + value + } +} diff --git a/src/server/metric_collection/mod.rs b/src/server/metric_collection/mod.rs index dd5bca70..8278e001 100644 --- a/src/server/metric_collection/mod.rs +++ b/src/server/metric_collection/mod.rs @@ -7,7 +7,6 @@ use std::{ use anyhow::Error; use pbs_api_types::{DataStoreConfig, Operation}; -use serde_json::{json, Value}; use tokio::join; use proxmox_sys::{ @@ -95,26 +94,6 @@ struct DiskStat { dev: Option, } -impl DiskStat { - fn to_value(&self) -> Value { - let mut value = json!({}); - if let Some(usage) = &self.usage { - value["total"] = Value::from(usage.total); - value["used"] = Value::from(usage.used); - value["avail"] = Value::from(usage.available); - } - - if let Some(dev) = &self.dev { - value["read_ios"] = Value::from(dev.read_ios); - value["read_bytes"] = Value::from(dev.read_sectors * 512); - value["write_ios"] = Value::from(dev.write_ios); - value["write_bytes"] = Value::from(dev.write_sectors * 512); - value["io_ticks"] = Value::from(dev.io_ticks / 1000); - } - value - } -} - fn collect_host_stats_sync() -> HostStats { use proxmox_sys::linux::procfs::{ read_loadavg, read_meminfo, read_proc_net_dev, read_proc_stat, -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel