Commit f274147a authored by Wolfgang Link's avatar Wolfgang Link Committed by Dietmar Maurer

fix output percent_used in rbd pools

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
parent 6346d5d5
...@@ -1125,8 +1125,8 @@ __PACKAGE__->register_method ({ ...@@ -1125,8 +1125,8 @@ __PACKAGE__->register_method ({
my $stats = {}; my $stats = {};
my $res = $rados->mon_command({ prefix => 'df' }); my $res = $rados->mon_command({ prefix => 'df' });
my $total = $res->{stats}->{total_space} || 0; my $total = $res->{stats}->{total_avail_bytes} || 0;
$total = $total * 1024;
foreach my $d (@{$res->{pools}}) { foreach my $d (@{$res->{pools}}) {
next if !$d->{stats}; next if !$d->{stats};
next if !defined($d->{id}); next if !defined($d->{id});
...@@ -1143,8 +1143,8 @@ __PACKAGE__->register_method ({ ...@@ -1143,8 +1143,8 @@ __PACKAGE__->register_method ({
} }
if (my $s = $stats->{$d->{pool}}) { if (my $s = $stats->{$d->{pool}}) {
$d->{bytes_used} = $s->{bytes_used}; $d->{bytes_used} = $s->{bytes_used};
$d->{percent_used} = ($d->{bytes_used}*$d->{size}*100)/$total $d->{percent_used} = ($s->{bytes_used} / $total)*100
if $d->{size} && $total; if $s->{max_avail} && $total;
} }
push @$data, $d; push @$data, $d;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment