1 Ext
.define('pve-ceph-warnings', {
2 extend
: 'Ext.data.Model',
3 fields
: ['id', 'summary', 'detail', 'severity'],
8 Ext
.define('PVE.node.CephStatus', {
9 extend
: 'Ext.panel.Panel',
10 alias
: 'widget.pveNodeCephStatus',
12 onlineHelp
: 'chapter_pveceph',
27 title
: gettext('Health'),
29 plugins
: 'responsive',
55 xtype
: 'pveHealthWidget',
56 itemId
: 'overallhealth',
58 title
: gettext('Status'),
61 xtype
: 'displayfield',
62 itemId
: 'versioninfo',
63 fieldLabel
: gettext('Ceph Version'),
67 'data-qtip': gettext('The newest version installed in the Cluster.'),
71 'text-align': 'center',
82 stateId
: 'ceph-status-warnings',
84 enableTextSelection
: true,
86 // we load the store manually, to show an emptyText specify an empty intermediate store
92 storeid
: 'pve-ceph-warnings',
94 model
: 'pve-ceph-warnings',
97 updateHealth: function(health
) {
98 let checks
= health
.checks
|| {};
100 let checkRecords
= Object
.keys(checks
).sort().map(key
=> {
101 let check
= checks
[key
];
104 summary
: check
.summary
.message
,
105 detail
: check
.detail
.reduce((acc
, v
) => `${acc}\n${v.message}`, '').trimStart(),
106 severity
: check
.severity
,
108 data
.noDetails
= data
.detail
.length
=== 0;
109 data
.detailsCls
= data
.detail
.length
=== 0 ? 'pmx-faded' : '';
110 if (data
.detail
.length
=== 0) {
111 data
.detail
= "no additional data";
116 let rstore
= this.getStore().rstore
;
117 rstore
.loadData(checkRecords
, false);
118 rstore
.fireEvent('load', rstore
, checkRecords
, true);
120 emptyText
: gettext('No Warnings/Errors'),
123 dataIndex
: 'severity',
124 tooltip
: gettext('Severity'),
127 renderer: function(value
) {
128 let health
= PVE
.Utils
.map_ceph_health
[value
];
129 let icon
= PVE
.Utils
.get_health_icon(health
);
130 return `<i class="fa fa-fw ${icon}"></i>`;
133 sorterFn: function(a
, b
) {
134 let health
= ['HEALTH_ERR', 'HEALTH_WARN', 'HEALTH_OK'];
135 return health
.indexOf(b
.data
.severity
) - health
.indexOf(a
.data
.severity
);
140 dataIndex
: 'summary',
141 header
: gettext('Summary'),
145 xtype
: 'actioncolumn',
148 tooltip
: gettext('Actions'),
151 iconCls
: 'x-fa fa-clipboard',
152 tooltip
: gettext('Copy to Clipboard'),
153 handler: function(grid
, rowindex
, colindex
, item
, e
, { data
}) {
154 let detail
= data
.noDetails
? '': `\n${data.detail}`;
156 .writeText(`${data.severity}: ${data.summary}${detail}`)
157 .catch(err
=> Ext
.Msg
.alert(gettext('Error'), err
));
164 itemdblclick: function(view
, record
, row
, rowIdx
, e
) {
165 // inspired by Ext.grid.plugin.RowExpander, but for double click
166 let rowNode
= view
.getNode(rowIdx
);
167 let normalRow
= Ext
.fly(rowNode
);
169 let collapsedCls
= view
.rowBodyFeature
.rowCollapsedCls
;
171 if (normalRow
.hasCls(collapsedCls
)) {
172 view
.rowBodyFeature
.rowExpander
.toggleRow(rowIdx
, record
);
178 ptype
: 'rowexpander',
179 expandOnDblClick
: false,
180 scrollIntoViewOnExpand
: false,
181 rowBodyTpl
: '<pre class="pve-ceph-warning-detail {detailsCls}">{detail}</pre>',
188 xtype
: 'pveCephStatusDetail',
189 itemId
: 'statusdetail',
190 plugins
: 'responsive',
201 title
: gettext('Status'),
204 xtype
: 'pveCephServices',
205 title
: gettext('Services'),
207 plugins
: 'responsive',
225 title
: gettext('Performance'),
238 xtype
: 'proxmoxGauge',
240 title
: gettext('Usage'),
253 xtype
: 'pveRunningChart',
254 itemId
: 'recoverychart',
255 title
: gettext('Recovery') +'/ '+ gettext('Rebalance'),
256 renderer
: PVE
.Utils
.render_bandwidth
,
260 xtype
: 'progressbar',
261 itemId
: 'recoveryprogress',
276 xtype
: 'pveRunningChart',
278 title
: gettext('Reads'),
279 renderer
: PVE
.Utils
.render_bandwidth
,
282 xtype
: 'pveRunningChart',
284 title
: gettext('Writes'),
285 renderer
: PVE
.Utils
.render_bandwidth
,
288 xtype
: 'pveRunningChart',
290 title
: 'IOPS: ' + gettext('Reads'),
291 renderer
: Ext
.util
.Format
.numberRenderer('0,000'),
294 xtype
: 'pveRunningChart',
296 title
: 'IOPS: ' + gettext('Writes'),
297 renderer
: Ext
.util
.Format
.numberRenderer('0,000'),
305 updateAll: function(store
, records
, success
) {
306 if (!success
|| records
.length
=== 0) {
311 var rec
= records
[0];
312 me
.status
= rec
.data
;
315 me
.down('#overallhealth').updateHealth(PVE
.Utils
.render_ceph_health(rec
.data
.health
|| {}));
316 me
.down('#warnings').updateHealth(rec
.data
.health
|| {}); // add errors to gridstore
318 me
.getComponent('services').updateAll(me
.metadata
|| {}, rec
.data
);
320 me
.getComponent('statusdetail').updateAll(me
.metadata
|| {}, rec
.data
);
322 // add performance data
323 let pgmap
= rec
.data
.pgmap
;
324 let used
= pgmap
.bytes_used
;
325 let total
= pgmap
.bytes_total
;
327 var text
= Ext
.String
.format(gettext('{0} of {1}'),
328 Proxmox
.Utils
.render_size(used
),
329 Proxmox
.Utils
.render_size(total
),
332 // update the usage widget
333 me
.down('#space').updateValue(used
/total
, text
);
335 let readiops
= pgmap
.read_op_per_sec
;
336 let writeiops
= pgmap
.write_op_per_sec
;
337 let reads
= pgmap
.read_bytes_sec
|| 0;
338 let writes
= pgmap
.write_bytes_sec
|| 0;
341 me
.reads
.addDataPoint(reads
);
342 me
.writes
.addDataPoint(writes
);
343 me
.readiops
.addDataPoint(readiops
);
344 me
.writeiops
.addDataPoint(writeiops
);
346 let degraded
= pgmap
.degraded_objects
|| 0;
347 let misplaced
= pgmap
.misplaced_objects
|| 0;
348 let unfound
= pgmap
.unfound_objects
|| 0;
349 let unhealthy
= degraded
+ unfound
+ misplaced
;
351 if (pgmap
.recovering_objects_per_sec
!== undefined || unhealthy
> 0) {
352 let toRecoverObjects
= pgmap
.misplaced_total
|| pgmap
.unfound_total
|| pgmap
.degraded_total
|| 0;
353 if (toRecoverObjects
=== 0) {
354 return; // FIXME: unexpected return and leaves things possible visible when it shouldn't?
356 let recovered
= toRecoverObjects
- unhealthy
|| 0;
357 let speed
= pgmap
.recovering_bytes_per_sec
|| 0;
359 let recoveryRatio
= recovered
/ toRecoverObjects
;
360 let txt
= `${(recoveryRatio * 100).toFixed(2)}%`;
362 let obj_per_sec
= speed
/ (4 * 1024 * 1024); // 4 MiB per Object
363 let duration
= Proxmox
.Utils
.format_duration_human(unhealthy
/obj_per_sec
);
364 let speedTxt
= PVE
.Utils
.render_bandwidth(speed
);
365 txt
+= ` (${speedTxt} - ${duration} left)`;
368 me
.down('#recovery').setVisible(true);
369 me
.down('#recoveryprogress').updateValue(recoveryRatio
);
370 me
.down('#recoveryprogress').updateText(txt
);
371 me
.down('#recoverychart').addDataPoint(speed
);
373 me
.down('#recovery').setVisible(false);
374 me
.down('#recoverychart').addDataPoint(0);
378 initComponent: function() {
381 var nodename
= me
.pveSelNode
.data
.node
;
384 var baseurl
= '/api2/json' + (nodename
? '/nodes/' + nodename
: '/cluster') + '/ceph';
385 me
.store
= Ext
.create('Proxmox.data.UpdateStore', {
386 storeid
: 'ceph-status-' + (nodename
|| 'cluster'),
390 url
: baseurl
+ '/status',
394 me
.metadatastore
= Ext
.create('Proxmox.data.UpdateStore', {
395 storeid
: 'ceph-metadata-' + (nodename
|| 'cluster'),
399 url
: '/api2/json/cluster/ceph/metadata',
403 // save references for the updatefunction
404 me
.iops
= me
.down('#iops');
405 me
.readiops
= me
.down('#readiops');
406 me
.writeiops
= me
.down('#writeiops');
407 me
.reads
= me
.down('#reads');
408 me
.writes
= me
.down('#writes');
410 // manages the "install ceph?" overlay
411 PVE
.Utils
.monitor_ceph_installed(me
, me
.store
, nodename
);
413 me
.mon(me
.store
, 'load', me
.updateAll
, me
);
414 me
.mon(me
.metadatastore
, 'load', function(store
, records
, success
) {
415 if (!success
|| records
.length
< 1) {
418 me
.metadata
= records
[0].data
;
421 me
.getComponent('services').updateAll(me
.metadata
, me
.status
|| {});
423 // update detailstatus panel
424 me
.getComponent('statusdetail').updateAll(me
.metadata
, me
.status
|| {});
427 let maxversiontext
= "";
428 for (const [_nodename
, data
] of Object
.entries(me
.metadata
.node
)) {
429 let version
= data
.version
.parts
;
430 if (PVE
.Utils
.compare_ceph_versions(version
, maxversion
) > 0) {
431 maxversion
= version
;
432 maxversiontext
= data
.version
.str
;
435 me
.down('#versioninfo').setValue(maxversiontext
);
438 me
.on('destroy', me
.store
.stopUpdate
);
439 me
.on('destroy', me
.metadatastore
.stopUpdate
);
440 me
.store
.startUpdate();
441 me
.metadatastore
.startUpdate();