From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CFAF17358E for ; Fri, 27 May 2022 12:58:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BF3ABD110 for ; Fri, 27 May 2022 12:58:03 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 40BF3D0FA for ; Fri, 27 May 2022 12:58:02 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1456C438C1 for ; Fri, 27 May 2022 12:58:02 +0200 (CEST) From: Daniel Tschlatscher To: pbs-devel@lists.proxmox.com Date: Fri, 27 May 2022 12:57:28 +0200 Message-Id: <20220527105728.132412-2-d.tschlatscher@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527105728.132412-1-d.tschlatscher@proxmox.com> References: <20220527105728.132412-1-d.tschlatscher@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.117 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH proxmox-backup 1/1] fix #4077: Estimated Full metric on ext4 file systems 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: , X-List-Received-Date: Fri, 27 May 2022 10:58:33 -0000 The estimated full statistics metric no longer uses the total amount of space on a disk, but rather the still available. Also refactored some variable names for the 'estimated_full' calculation to make it clearer what changed/is used now. Note: Statistics for 'available' were not tracked in the rrdb before, existing datastores will therefore show a somewhat incorrect value for 'estimated_full', at least until it is populated with enough new values. Signed-off-by: Daniel Tschlatscher --- src/api2/status.rs | 14 +++++++------- src/bin/proxmox-backup-proxy.rs | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/api2/status.rs b/src/api2/status.rs index 45aa7fd7..f7d96c49 100644 --- a/src/api2/status.rs +++ b/src/api2/status.rs @@ -88,25 +88,25 @@ pub fn datastore_status( let get_rrd = |what: &str| extract_rrd_data(&rrd_dir, what, RRDTimeFrame::Month, RRDMode::Average); - let total_res = get_rrd("total")?; + let avail_res = get_rrd("available")?; let used_res = get_rrd("used")?; - if let (Some((start, reso, total_list)), Some((_, _, used_list))) = (total_res, used_res) { + if let (Some((start, reso, avail_list)), Some((_, _, used_list))) = (avail_res, used_res) { let mut usage_list: Vec = Vec::new(); let mut time_list: Vec = Vec::new(); let mut history = Vec::new(); for (idx, used) in used_list.iter().enumerate() { - let total = if idx < total_list.len() { - total_list[idx] + let available = if idx < avail_list.len() { + avail_list[idx] } else { None }; - match (total, used) { - (Some(total), Some(used)) if total != 0.0 => { + match (available, used) { + (Some(available), Some(used)) if available != 0.0 => { time_list.push(start + (idx as u64) * reso); - let usage = used / total; + let usage = used / available; usage_list.push(usage); history.push(Some(usage)); } diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 659f7b4a..82f40a54 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -1140,6 +1140,8 @@ fn gather_disk_stats(disk_manager: Arc, path: &Path, rrd_prefix: &st rrd_update_gauge(&rrd_key, status.total as f64); let rrd_key = format!("{}/used", rrd_prefix); rrd_update_gauge(&rrd_key, status.used as f64); + let rrd_key = format!("{}/available", rrd_prefix); + rrd_update_gauge(&rrd_key, status.avail as f64); } Err(err) => { eprintln!("read disk_usage on {:?} failed - {}", path, err); -- 2.30.2