]> git.proxmox.com Git - pve-manager.git/commitdiff
include a 'status' field for storages
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 3 Nov 2017 08:51:33 +0000 (09:51 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 14 Nov 2017 12:27:07 +0000 (13:27 +0100)
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@proxmox.com>
PVE/API2Tools.pm

index 2956b5ad8ac7b0cc1c588d473441ae46e501bf60..7e0fdf47f0e7e7997804aa766270282b017366c4 100644 (file)
@@ -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;