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 {
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 ({
name => 'index',
path => '',
......@@ -69,6 +83,8 @@ __PACKAGE__->register_method ({
my $osdhash = &$get_osd_status($rados);
my $usagehash = &$get_osd_usage($rados);
my $nodes = {};
my $newnodes = {};
foreach my $e (@{$res->{nodes}}) {
......@@ -88,6 +104,12 @@ __PACKAGE__->register_method ({
$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;
}
......
......@@ -170,12 +170,11 @@ Ext.define('PVE.node.CephPoolList', {
header: gettext('Used'),
columns: [
{
xtype: 'numbercolumn',
header: '%',
width: 80,
sortable: true,
align: 'right',
format: '0.00',
renderer: Ext.util.Format.numberRenderer('0.00'),
dataIndex: 'percent_used'
},
{
......@@ -446,6 +445,9 @@ Ext.define('PVE.node.CephOsdTree', {
fields: ['name', 'type', 'status', 'host', 'in',
{ type: 'integer', name: 'id' },
{ type: 'number', name: 'reweight' },
{ type: 'number', name: 'percent_used' },
{ type: 'integer', name: 'bytes_used' },
{ type: 'integer', name: 'total_space' },
{ type: 'number', name: 'crush_weight' }],
stateful: false,
selModel: sm,
......@@ -454,25 +456,13 @@ Ext.define('PVE.node.CephOsdTree', {
xtype: 'treecolumn',
text: 'Name',
dataIndex: 'name',
width: 200
},
{
text: 'ID',
dataIndex: 'id',
align: 'right',
width: 60
},
{
text: 'weight',
dataIndex: 'crush_weight',
align: 'right',
width: 60
width: 150
},
{
text: 'Type',
dataIndex: 'type',
align: 'right',
width: 100
width: 60
},
{
text: 'Status',
......@@ -485,13 +475,55 @@ Ext.define('PVE.node.CephOsdTree', {
var data = rec.data;
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',
dataIndex: 'reweight',
align: 'right',
renderer: function(value, metaData, rec) {
if (rec.data.type !== 'osd') {
return '';
}
return value;
},
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: {
......
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