[pve-devel] [PATCH manager v4 2/8] include a 'status' field for storages
Dominik Csapak
d.csapak at proxmox.com
Fri Nov 3 09:51:33 CET 2017
by default it is unknown, if the storage is >= 60% full, it is
'nearfull', if it is >= 90% full, it is 'full'
if we have any other information, it is 'available'
we can use this information for the tree
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes since v3:
* return either 'full', 'nearfull', 'available', or 'unknown'
my plan is, to make the (near)full thresholds, customizable,
also in other parts of the gui
PVE/API2Tools.pm | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/PVE/API2Tools.pm b/PVE/API2Tools.pm
index 2956b5ad..7e0fdf47 100644
--- a/PVE/API2Tools.pm
+++ b/PVE/API2Tools.pm
@@ -118,11 +118,22 @@ sub extract_storage_stats {
storage => $storeid,
node => $node,
type => 'storage',
+ status => 'unknown',
};
if (my $d = $rrd->{"pve2-storage/$node/$storeid"}) {
$entry->{maxdisk} = ($d->[1] || 0) + 0;
$entry->{disk} = ($d->[2] || 0) + 0;
+ $entry->{status} = 'available';
+ if ($entry->{disk} > 0 && $entry->{maxdisk} > 0) {
+ my $usage = $entry->{disk} / $entry->{maxdisk};
+
+ if ($usage >= 0.9) {
+ $entry->{status} = 'full';
+ } elsif ($usage >= 0.6) {
+ $entry->{status} = 'nearfull';
+ }
+ }
}
return $entry;
--
2.11.0
More information about the pve-devel
mailing list