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 DA45E1FF15E for ; Mon, 27 Oct 2025 15:25:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CA1967A87; Mon, 27 Oct 2025 15:26:07 +0100 (CET) From: Christian Ebner To: pdm-devel@lists.proxmox.com Date: Mon, 27 Oct 2025 15:25:49 +0100 Message-ID: <20251027142551.458160-4-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251027142551.458160-1-c.ebner@proxmox.com> References: <20251027142551.458160-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761575152425 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.043 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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] [RFC datacenter-manager 3/5] server: resources: account for datastores with upwards usage trend 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" Count datastores for which the estimated full date is within 7 days as uptrend usage. This is in preparation for showing these in the PBS datastore statistics panel. Signed-off-by: Christian Ebner --- server/src/api/resources.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs index 586c732..97224f7 100644 --- a/server/src/api/resources.rs +++ b/server/src/api/resources.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use std::str::FromStr; use std::sync::{LazyLock, RwLock}; +use std::time::{SystemTime, UNIX_EPOCH}; use anyhow::{bail, format_err, Error}; use futures::future::join_all; @@ -14,7 +15,7 @@ use pdm_api_types::resource::{ FailedRemote, PbsDatastoreResource, PbsNodeResource, PveLxcResource, PveNodeResource, PveQemuResource, PveSdnResource, PveStorageResource, RemoteResources, Resource, ResourceType, ResourcesStatus, SdnStatus, SdnZoneResource, TopEntities, - PBS_DATASTORE_CRITICAL_USAGE_THRESHOLD, + PBS_DATASTORE_CRITICAL_USAGE_THRESHOLD, PBS_DATASTORE_FILLUP_THRESHOLD, }; use pdm_api_types::subscription::{ NodeSubscriptionInfo, RemoteSubscriptionState, RemoteSubscriptions, SubscriptionLevel, @@ -468,6 +469,20 @@ pub async fn get_status( if r.usage > PBS_DATASTORE_CRITICAL_USAGE_THRESHOLD { *counts.pbs_datastores.critical_usage.get_or_insert_default() += 1; } + if let Some(estimated_full) = r.estimated_full_date { + if let Ok(now) = SystemTime::now().duration_since(UNIX_EPOCH) { + let threshold = now.as_secs() + PBS_DATASTORE_FILLUP_THRESHOLD; + if estimated_full > 0 + && (estimated_full as u64) > now.as_secs() + && (estimated_full as u64) < threshold + { + *counts + .pbs_datastores + .uptrending_usage + .get_or_insert_default() += 1; + } + } + } if r.backing_device.is_some() { *counts.pbs_datastores.removable.get_or_insert_default() += 1; } @@ -1074,6 +1089,7 @@ fn map_pbs_datastore_status( maintenance: store_config.maintenance_mode.clone(), backing_device: store_config.backing_device.clone(), backend_type, + estimated_full_date: status.estimated_full_date, }) } else { Resource::PbsDatastore(PbsDatastoreResource { @@ -1082,6 +1098,7 @@ fn map_pbs_datastore_status( maxdisk, disk, usage, + estimated_full_date: status.estimated_full_date, ..Default::default() }) } -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel