[pve-devel] [PATCH manager] add %USED calculation for pre luminous clusters

Alwin Antreich a.antreich at proxmox.com
Fri Nov 3 10:48:18 CET 2017


Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
---
 PVE/API2/Ceph.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index efea3059..a0260fe2 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1522,6 +1522,18 @@ __PACKAGE__->register_method ({
 	    if (my $s = $stats->{$d->{pool}}) {
 		$d->{bytes_used} = $s->{bytes_used};
 		$d->{percent_used} = $s->{percent_used};
+
+		if (!defined($d->{percent_used})) {
+		    my $o = $rados->mon_command({ prefix => 'pg dump' });
+		    foreach my $p (@{$o->{pool_stats}}) {
+			if ($p->{poolid} == $d->{pool}) {
+			    my $stat = $p->{stat_sum};
+			    my $used = $stat->{num_bytes} * (($stat->{num_object_copies} - $stat->{num_objects_degraded}) / $stat->{num_object_copies});
+			    $used /= ($used + $s->{max_avail});
+			$d->{percent_used} = $used * 100;
+			}
+		    }
+		}
 	    }
 	    push @$data, $d;
 	}
--
2.11.0





More information about the pve-devel mailing list