[pve-devel] [PATCH storage 1/2] Fix: 1542 - show storage utilization per pool, not per global
Alexandre DERUMIER
aderumier at odiso.com
Wed Nov 15 17:16:52 CET 2017
Hi,
Could it be possible to use replication factor from pool config to display used and free space ?
(/3 if size=3 for example)
We didn't do it before, but I think this was because we monitor the full storage,
now that it's only for a specific pool, I think it can make sense.
----- Mail original -----
De: "Alwin Antreich" <a.antreich at proxmox.com>
À: "pve-devel" <pve-devel at pve.proxmox.com>
Envoyé: Mercredi 15 Novembre 2017 15:47:27
Objet: [pve-devel] [PATCH storage 1/2] Fix: 1542 - show storage utilization per pool, not per global
Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
---
PVE/Storage/RBDPlugin.pm | 40 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index decfbf5..14386c4 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -7,6 +7,7 @@ use Net::IP;
use PVE::Tools qw(run_command trim);
use PVE::Storage::Plugin;
use PVE::JSONSchema qw(get_standard_option);
+use PVE::RADOS;
use base qw(PVE::Storage::Plugin);
@@ -90,6 +91,15 @@ my $rados_cmd = sub {
return $build_cmd->('/usr/bin/rados', $scfg, $storeid, $op, @options);
};
+my $rados_mon_cmd = sub {
+ my ($cmd) = @_;
+
+ my $rados = PVE::RADOS->new();
+ my $res = $rados->mon_command({ prefix => $cmd, format => 'json' });
+
+ return $res;
+};
+
# needed for volumes created using ceph jewel (or higher)
my $krdb_feature_disable = sub {
my ($scfg, $storeid, $name) = @_;
@@ -527,32 +537,20 @@ sub list_images {
sub status {
my ($class, $storeid, $scfg, $cache) = @_;
- my $cmd = &$rados_cmd($scfg, $storeid, 'df');
-
- my $stats = {};
-
- my $parser = sub {
- my $line = shift;
- if ($line =~ m/^\s*total(?:\s|_)(\S+)\s+(\d+)(k|M|G|T)?/) {
- $stats->{$1} = $2;
- # luminous has units here..
- if ($3) {
- $stats->{$1} *= $rbd_unittobytes->{$3}/1024;
- }
- }
- };
-
- eval {
- run_rbd_command($cmd, errmsg => "rados error", errfunc => sub {}, outfunc => $parser);
- };
+ my $df_cmd = &$rados_mon_cmd('df');
+ my $pg_cmd = &$rados_mon_cmd('pg dump');
- my $total = $stats->{space} ? $stats->{space}*1024 : 0;
- my $free = $stats->{avail} ? $stats->{avail}*1024 : 0;
- my $used = $stats->{used} ? $stats->{used}*1024: 0;
+ foreach my $d (@{$df_cmd->{pools}}) {
+ next if ($d->{name} ne $scfg->{pool});
+ my $s_df = $d->{stats};
+ my $free = $s_df->{max_avail};
+ my $used = $s_df->{bytes_used};
+ my $total = $used + $free;
my $active = 1;
return ($total, $free, $used, $active);
}
+}
sub activate_storage {
my ($class, $storeid, $scfg, $cache) = @_;
--
2.11.0
_______________________________________________
pve-devel mailing list
pve-devel at pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list