public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [RFC datacenter-manager 5/5] pdm-api-types: calculate upwards trending datastore usage property
Date: Mon, 27 Oct 2025 15:25:51 +0100	[thread overview]
Message-ID: <20251027142551.458160-6-c.ebner@proxmox.com> (raw)
In-Reply-To: <20251027142551.458160-1-c.ebner@proxmox.com>

To allow filtering of PBS datastore resources with upwards trending
storage usage. Calculate base on the current system time.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 lib/pdm-api-types/src/resource.rs | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs
index 10ea123..c7f24c2 100644
--- a/lib/pdm-api-types/src/resource.rs
+++ b/lib/pdm-api-types/src/resource.rs
@@ -1,4 +1,5 @@
 use std::convert::Infallible;
+use std::time::{SystemTime, UNIX_EPOCH};
 
 use anyhow::{bail, Error};
 use serde::{Deserialize, Serialize};
@@ -122,6 +123,17 @@ impl Resource {
             if r.usage > PBS_DATASTORE_CRITICAL_USAGE_THRESHOLD {
                 properties.push("critical-usage".to_string());
             }
+            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
+                    {
+                        properties.push("uptrendig-usage".to_string());
+                    }
+                }
+            }
         }
         properties.join(",")
     }
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


      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 ` [pdm-devel] [RFC datacenter-manager 3/5] server: resources: account for datastores with upwards usage trend Christian Ebner
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 ` Christian Ebner [this message]

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-6-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal