[pve-devel] [PATCH] fix output percent_used in rbd pools

Wolfgang Link w.link at proxmox.com
Mon Sep 7 12:48:31 CEST 2015


This fix is essential of cause json field changes in the ceph api.
They change the field size in pool to max_avail
and the field total_size in stats to total_max_avail
---
 PVE/API2/Ceph.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 8a8581f..2aef6b1 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1125,8 +1125,8 @@ __PACKAGE__->register_method ({
 
 	my $stats = {};
 	my $res = $rados->mon_command({ prefix => 'df' });
-	my $total = $res->{stats}->{total_space} || 0;
-	$total = $total * 1024;
+	my $total = $res->{stats}->{total_avail_bytes} || 0;
+
 	foreach my $d (@{$res->{pools}}) {
 	    next if !$d->{stats};
 	    next if !defined($d->{id});
@@ -1143,8 +1143,8 @@ __PACKAGE__->register_method ({
 	    }
 	    if (my $s = $stats->{$d->{pool}}) {
 		$d->{bytes_used} = $s->{bytes_used};
-		$d->{percent_used} = ($d->{bytes_used}*$d->{size}*100)/$total 
-		    if $d->{size} && $total;
+		$d->{percent_used} = ($s->{bytes_used} / $total)*100
+		    if $s->{max_avail} && $total;
 	    }
 	    push @$data, $d;
 	}
-- 
2.1.4





More information about the pve-devel mailing list