Commit 92e4d5fc authored by Dietmar Maurer's avatar Dietmar Maurer

ceph: display osd usage

parent 0c7ba3e3
...@@ -40,6 +40,20 @@ my $get_osd_status = sub { ...@@ -40,6 +40,20 @@ my $get_osd_status = sub {
return $osdstat; return $osdstat;
}; };
my $get_osd_usage = sub {
my ($rados) = @_;
my $osdlist = $rados->mon_command({ prefix => 'pg dump',
dumpcontents => [ 'osds' ]}) || [];
my $osdstat;
foreach my $d (@$osdlist) {
$osdstat->{$d->{osd}} = $d if defined($d->{osd});
}
return $osdstat;
};
__PACKAGE__->register_method ({ __PACKAGE__->register_method ({
name => 'index', name => 'index',
path => '', path => '',
...@@ -69,6 +83,8 @@ __PACKAGE__->register_method ({ ...@@ -69,6 +83,8 @@ __PACKAGE__->register_method ({
my $osdhash = &$get_osd_status($rados); my $osdhash = &$get_osd_status($rados);
my $usagehash = &$get_osd_usage($rados);
my $nodes = {}; my $nodes = {};
my $newnodes = {}; my $newnodes = {};
foreach my $e (@{$res->{nodes}}) { foreach my $e (@{$res->{nodes}}) {
...@@ -88,6 +104,12 @@ __PACKAGE__->register_method ({ ...@@ -88,6 +104,12 @@ __PACKAGE__->register_method ({
$new->{in} = $stat->{in} if defined($stat->{in}); $new->{in} = $stat->{in} if defined($stat->{in});
} }
if (my $stat = $usagehash->{$e->{id}}) {
$new->{total_space} = ($stat->{kb} || 1) * 1024;
$new->{bytes_used} = ($stat->{kb_used} || 0) * 1024;
$new->{percent_used} = ($new->{bytes_used}*100)/$new->{total_space};
}
$newnodes->{$e->{id}} = $new; $newnodes->{$e->{id}} = $new;
} }
......
...@@ -170,12 +170,11 @@ Ext.define('PVE.node.CephPoolList', { ...@@ -170,12 +170,11 @@ Ext.define('PVE.node.CephPoolList', {
header: gettext('Used'), header: gettext('Used'),
columns: [ columns: [
{ {
xtype: 'numbercolumn',
header: '%', header: '%',
width: 80, width: 80,
sortable: true, sortable: true,
align: 'right', align: 'right',
format: '0.00', renderer: Ext.util.Format.numberRenderer('0.00'),
dataIndex: 'percent_used' dataIndex: 'percent_used'
}, },
{ {
...@@ -446,6 +445,9 @@ Ext.define('PVE.node.CephOsdTree', { ...@@ -446,6 +445,9 @@ Ext.define('PVE.node.CephOsdTree', {
fields: ['name', 'type', 'status', 'host', 'in', fields: ['name', 'type', 'status', 'host', 'in',
{ type: 'integer', name: 'id' }, { type: 'integer', name: 'id' },
{ type: 'number', name: 'reweight' }, { type: 'number', name: 'reweight' },
{ type: 'number', name: 'percent_used' },
{ type: 'integer', name: 'bytes_used' },
{ type: 'integer', name: 'total_space' },
{ type: 'number', name: 'crush_weight' }], { type: 'number', name: 'crush_weight' }],
stateful: false, stateful: false,
selModel: sm, selModel: sm,
...@@ -454,25 +456,13 @@ Ext.define('PVE.node.CephOsdTree', { ...@@ -454,25 +456,13 @@ Ext.define('PVE.node.CephOsdTree', {
xtype: 'treecolumn', xtype: 'treecolumn',
text: 'Name', text: 'Name',
dataIndex: 'name', dataIndex: 'name',
width: 200 width: 150
},
{
text: 'ID',
dataIndex: 'id',
align: 'right',
width: 60
},
{
text: 'weight',
dataIndex: 'crush_weight',
align: 'right',
width: 60
}, },
{ {
text: 'Type', text: 'Type',
dataIndex: 'type', dataIndex: 'type',
align: 'right', align: 'right',
width: 100 width: 60
}, },
{ {
text: 'Status', text: 'Status',
...@@ -485,13 +475,55 @@ Ext.define('PVE.node.CephOsdTree', { ...@@ -485,13 +475,55 @@ Ext.define('PVE.node.CephOsdTree', {
var data = rec.data; var data = rec.data;
return value + '/' + (data['in'] ? 'in' : 'out'); return value + '/' + (data['in'] ? 'in' : 'out');
}, },
width: 100 width: 60
},
{
text: 'weight',
dataIndex: 'crush_weight',
align: 'right',
renderer: function(value, metaData, rec) {
if (rec.data.type !== 'osd') {
return '';
}
return value;
},
width: 60
}, },
{ {
text: 'reweight', text: 'reweight',
dataIndex: 'reweight', dataIndex: 'reweight',
align: 'right', align: 'right',
renderer: function(value, metaData, rec) {
if (rec.data.type !== 'osd') {
return '';
}
return value;
},
width: 60 width: 60
},
{
text: gettext('Size'),
dataIndex: 'total_space',
align: 'right',
renderer: function(value, metaData, rec) {
if (rec.data.type !== 'osd') {
return '';
}
return PVE.Utils.render_size(value);
},
width: 100
},
{
text: gettext('Used') + ' %',
dataIndex: 'percent_used',
align: 'right',
renderer: function(value, metaData, rec) {
if (rec.data.type !== 'osd') {
return '';
}
return Ext.util.Format.number(value, '0.00');
},
width: 80
} }
], ],
listeners: { listeners: {
......
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