From: Christian Ebner <c.ebner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [RFC datacenter-manager 3/5] server: resources: account for datastores with upwards usage trend
Date: Mon, 27 Oct 2025 15:25:49 +0100 [thread overview]
Message-ID: <20251027142551.458160-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20251027142551.458160-1-c.ebner@proxmox.com>
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 <c.ebner@proxmox.com>
---
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
next prev parent reply other threads:[~2025-10-27 14:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 14:25 [pdm-devel] [RFC datacenter-manager 0/5] show uptrending datastores in dashboard panel Christian Ebner
2025-10-27 14:25 ` [pdm-devel] [RFC datacenter-manager 1/5] pdm-api-types/ui/resources: rename and bump PBS datastore high-usage Christian Ebner
2025-10-27 14:25 ` [pdm-devel] [RFC datacenter-manager 2/5] pdm-api-types: extend datastore resources by optional estimated full Christian Ebner
2025-10-27 14:25 ` Christian Ebner [this message]
2025-10-27 14:25 ` [pdm-devel] [RFC datacenter-manager 4/5] ui: dashboard: show datastores with upwards trend in stats panel Christian Ebner
2025-10-27 14:25 ` [pdm-devel] [RFC datacenter-manager 5/5] pdm-api-types: calculate upwards trending datastore usage property Christian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251027142551.458160-4-c.ebner@proxmox.com \
--to=c.ebner@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox