Commit 0c7ba3e3 authored by Dietmar Maurer's avatar Dietmar Maurer

ceph: display pool usage information

parent 252d499d
......@@ -1094,7 +1094,18 @@ __PACKAGE__->register_method ({
PVE::CephTools::check_ceph_inited();
my $rados = PVE::RADOS->new();
my $res = $rados->mon_command({ prefix => 'osd dump' });
my $stats = {};
my $res = $rados->mon_command({ prefix => 'df' });
my $total = $res->{stats}->{total_space} || 0;
$total = $total * 1024;
foreach my $d (@{$res->{pools}}) {
next if !$d->{stats};
next if !defined($d->{id});
$stats->{$d->{id}} = $d->{stats};
}
$res = $rados->mon_command({ prefix => 'osd dump' });
my $data = [];
foreach my $e (@{$res->{pools}}) {
......@@ -1102,9 +1113,14 @@ __PACKAGE__->register_method ({
foreach my $attr (qw(pool pool_name size min_size pg_num crush_ruleset)) {
$d->{$attr} = $e->{$attr} if defined($e->{$attr});
}
if (my $s = $stats->{$d->{pool}}) {
$d->{bytes_used} = $s->{bytes_used};
$d->{percent_used} = ($d->{bytes_used}*100)/$total if $total;
}
push @$data, $d;
}
return $data;
}});
......
......@@ -117,9 +117,9 @@ my $cmddef = {
lspools => [ 'PVE::API2::Ceph', 'lspools', [], { node => $nodename }, sub {
my $res = shift;
printf("%-20s %10s %10s\n", "Name", "size", "pg_num");
printf("%-20s %10s %10s %20s\n", "Name", "size", "pg_num", "used");
foreach my $p (sort {$a->{pool_name} cmp $b->{pool_name}} @$res) {
printf("%-20s %10d %10d\n", $p->{pool_name}, $p->{size}, $p->{pg_num});
printf("%-20s %10d %10d %20d\n", $p->{pool_name}, $p->{size}, $p->{pg_num}, $p->{bytes_used});
}
}],
createpool => [ 'PVE::API2::Ceph', 'createpool', ['name'], { node => $nodename }],
......
......@@ -165,6 +165,28 @@ Ext.define('PVE.node.CephPoolList', {
width: 50,
sortable: false,
dataIndex: 'crush_ruleset'
},
{
header: gettext('Used'),
columns: [
{
xtype: 'numbercolumn',
header: '%',
width: 80,
sortable: true,
align: 'right',
format: '0.00',
dataIndex: 'percent_used'
},
{
header: gettext('Total'),
width: 100,
sortable: true,
renderer: PVE.Utils.render_size,
align: 'right',
dataIndex: 'bytes_used'
}
]
}
],
listeners: {
......@@ -185,6 +207,8 @@ Ext.define('PVE.node.CephPoolList', {
{ name: 'size', type: 'integer'},
{ name: 'min_size', type: 'integer'},
{ name: 'pg_num', type: 'integer'},
{ name: 'bytes_used', type: 'integer'},
{ name: 'percent_used', type: 'number'},
{ name: 'crush_ruleset', type: 'integer'}
],
idProperty: 'pool_name'
......
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