From b82c30328f87fc7439832cab60fd0254040d4e95 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 10 Dec 2021 02:42:31 +0300 Subject: [PATCH] Use vitastor-cli df to show pool stats in Proxmox --- patches/PVE_VitastorPlugin.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/patches/PVE_VitastorPlugin.pm b/patches/PVE_VitastorPlugin.pm index bc52d331c..8852750b2 100644 --- a/patches/PVE_VitastorPlugin.pm +++ b/patches/PVE_VitastorPlugin.pm @@ -339,11 +339,11 @@ sub list_images sub status { my ($class, $storeid, $scfg, $cache) = @_; - # FIXME: take it from etcd - my $free = 0; - my $used = 0; - my $total = $used + $free; - my $active = 1; + my $stats = [ grep { $_->{name} eq $scfg->{vitastor_pool} } @{ run_cli($scfg, [ 'df' ]) } ]->[0]; + my $free = $stats ? $stats->{max_available} : 0; + my $used = $stats ? $stats->{used_raw}/($stats->{raw_to_usable}||1) : 0; + my $total = $free+$used; + my $active = $stats ? 1 : 0; return ($total, $free, $used, $active); }