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

ceph: display pool usage information

parent 252d499d
...@@ -1094,7 +1094,18 @@ __PACKAGE__->register_method ({ ...@@ -1094,7 +1094,18 @@ __PACKAGE__->register_method ({
PVE::CephTools::check_ceph_inited(); PVE::CephTools::check_ceph_inited();
my $rados = PVE::RADOS->new(); 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 = []; my $data = [];
foreach my $e (@{$res->{pools}}) { foreach my $e (@{$res->{pools}}) {
...@@ -1102,9 +1113,14 @@ __PACKAGE__->register_method ({ ...@@ -1102,9 +1113,14 @@ __PACKAGE__->register_method ({
foreach my $attr (qw(pool pool_name size min_size pg_num crush_ruleset)) { foreach my $attr (qw(pool pool_name size min_size pg_num crush_ruleset)) {
$d->{$attr} = $e->{$attr} if defined($e->{$attr}); $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; push @$data, $d;
} }
return $data; return $data;
}}); }});
......
...@@ -117,9 +117,9 @@ my $cmddef = { ...@@ -117,9 +117,9 @@ my $cmddef = {
lspools => [ 'PVE::API2::Ceph', 'lspools', [], { node => $nodename }, sub { lspools => [ 'PVE::API2::Ceph', 'lspools', [], { node => $nodename }, sub {
my $res = shift; 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) { 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 }], createpool => [ 'PVE::API2::Ceph', 'createpool', ['name'], { node => $nodename }],
......
...@@ -165,6 +165,28 @@ Ext.define('PVE.node.CephPoolList', { ...@@ -165,6 +165,28 @@ Ext.define('PVE.node.CephPoolList', {
width: 50, width: 50,
sortable: false, sortable: false,
dataIndex: 'crush_ruleset' 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: { listeners: {
...@@ -185,6 +207,8 @@ Ext.define('PVE.node.CephPoolList', { ...@@ -185,6 +207,8 @@ Ext.define('PVE.node.CephPoolList', {
{ name: 'size', type: 'integer'}, { name: 'size', type: 'integer'},
{ name: 'min_size', type: 'integer'}, { name: 'min_size', type: 'integer'},
{ name: 'pg_num', type: 'integer'}, { name: 'pg_num', type: 'integer'},
{ name: 'bytes_used', type: 'integer'},
{ name: 'percent_used', type: 'number'},
{ name: 'crush_ruleset', type: 'integer'} { name: 'crush_ruleset', type: 'integer'}
], ],
idProperty: 'pool_name' 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