]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/ceph/Status.js
ui: ceph warnings: switch copy-details to copy-all
[pve-manager.git] / www / manager6 / ceph / Status.js
CommitLineData
459b6c31
AL
1Ext.define('pve-ceph-warnings', {
2 extend: 'Ext.data.Model',
3 fields: ['id', 'summary', 'detail', 'severity'],
4 idProperty: 'id',
5});
6
7
bd39c945 8Ext.define('PVE.node.CephStatus', {
946730cd
DC
9 extend: 'Ext.panel.Panel',
10 alias: 'widget.pveNodeCephStatus',
11
ba93a9c6 12 onlineHelp: 'chapter_pveceph',
bd39c945 13
946730cd 14 scrollable: true,
9f7cbaf3 15 bodyPadding: 5,
9f7cbaf3 16 layout: {
f6710aac 17 type: 'column',
9f7cbaf3 18 },
946730cd
DC
19
20 defaults: {
f6710aac 21 padding: 5,
946730cd
DC
22 },
23
24 items: [
25 {
26 xtype: 'panel',
27 title: gettext('Health'),
9f7cbaf3
DC
28 bodyPadding: 10,
29 plugins: 'responsive',
30 responsiveConfig: {
35279245 31 'width < 1600': {
27b91275 32 minHeight: 230,
f6710aac 33 columnWidth: 1,
9f7cbaf3 34 },
35279245 35 'width >= 1600': {
27b91275 36 minHeight: 500,
f6710aac
TL
37 columnWidth: 0.5,
38 },
9f7cbaf3 39 },
946730cd
DC
40 layout: {
41 type: 'hbox',
f6710aac 42 align: 'stretch',
946730cd
DC
43 },
44 items: [
45 {
949a6609
DC
46 xtype: 'container',
47 layout: {
48 type: 'vbox',
49 align: 'stretch',
50 },
946730cd 51 flex: 1,
949a6609
DC
52 items: [
53 {
616d54de 54
949a6609 55 xtype: 'pveHealthWidget',
616d54de
TL
56 itemId: 'overallhealth',
57 flex: 1,
f6710aac 58 title: gettext('Status'),
949a6609
DC
59 },
60 {
0beb2578 61 xtype: 'displayfield',
616d54de 62 itemId: 'versioninfo',
0beb2578
TL
63 fieldLabel: gettext('Ceph Version'),
64 value: "",
65 autoEl: {
66 tag: 'div',
67 'data-qtip': gettext('The newest version installed in the Cluster.'),
949a6609
DC
68 },
69 padding: '10 0 0 0',
70 style: {
71 'text-align': 'center',
72 },
f6710aac 73 },
0beb2578 74 ],
946730cd
DC
75 },
76 {
616d54de 77 xtype: 'grid',
946730cd 78 itemId: 'warnings',
616d54de 79 flex: 2,
459b6c31 80 maxHeight: 430,
946730cd
DC
81 stateful: true,
82 stateId: 'ceph-status-warnings',
459b6c31
AL
83 viewConfig: {
84 enableTextSelection: true,
85 },
10b00f3a 86 // we load the store manually, to show an emptyText specify an empty intermediate store
23f14fd9 87 store: {
459b6c31 88 type: 'diff',
ca0267fd 89 trackRemoved: false,
23f14fd9 90 data: [],
459b6c31
AL
91 rstore: {
92 storeid: 'pve-ceph-warnings',
93 type: 'update',
94 model: 'pve-ceph-warnings',
95 },
23f14fd9 96 },
b8febbcc
TL
97 updateHealth: function(health) {
98 let checks = health.checks || {};
99
100 let checkRecords = Object.keys(checks).sort().map(key => {
101 let check = checks[key];
459b6c31 102 let data = {
b8febbcc
TL
103 id: key,
104 summary: check.summary.message,
459b6c31 105 detail: check.detail.reduce((acc, v) => `${acc}\n${v.message}`, '').trimStart(),
b8febbcc
TL
106 severity: check.severity,
107 };
459b6c31
AL
108 if (data.detail.length === 0) {
109 data.detail = "no additional data";
110 }
111 return data;
b8febbcc
TL
112 });
113
459b6c31
AL
114 let rstore = this.getStore().rstore;
115 rstore.loadData(checkRecords, false);
116 rstore.fireEvent('load', rstore, checkRecords, true);
b8febbcc 117 },
946730cd
DC
118 emptyText: gettext('No Warnings/Errors'),
119 columns: [
120 {
121 dataIndex: 'severity',
459b6c31 122 tooltip: gettext('Severity'),
946730cd 123 align: 'center',
459b6c31 124 width: 38,
946730cd 125 renderer: function(value) {
10b00f3a
TL
126 let health = PVE.Utils.map_ceph_health[value];
127 let icon = PVE.Utils.get_health_icon(health);
5f2e6c2e 128 return `<i class="fa fa-fw ${icon}"></i>`;
946730cd
DC
129 },
130 sorter: {
f6710aac 131 sorterFn: function(a, b) {
10b00f3a
TL
132 let health = ['HEALTH_ERR', 'HEALTH_WARN', 'HEALTH_OK'];
133 return health.indexOf(b.data.severity) - health.indexOf(a.data.severity);
f6710aac
TL
134 },
135 },
946730cd
DC
136 },
137 {
138 dataIndex: 'summary',
139 header: gettext('Summary'),
f6710aac 140 flex: 1,
e932cd5f
DC
141 },
142 {
143 xtype: 'actioncolumn',
459b6c31 144 width: 50,
e932cd5f 145 align: 'center',
459b6c31 146 tooltip: gettext('Actions'),
e932cd5f
DC
147 items: [
148 {
459b6c31 149 iconCls: 'x-fa fa-files-o',
f2a0f0ec 150 tooltip: gettext('Copy Summary'),
459b6c31 151 handler: function(grid, rowindex, colindex, item, e, record) {
feb19220
TL
152 navigator.clipboard
153 .writeText(record.data.summary)
154 .catch(err => Ext.Msg.alert(gettext('Error'), err));
459b6c31
AL
155 },
156 },
157 {
158 iconCls: 'x-fa fa-clipboard',
f2a0f0ec
TL
159 tooltip: gettext('Copy All'),
160 handler: function(grid, rowindex, colindex, item, e, { data }) {
feb19220 161 navigator.clipboard
f2a0f0ec 162 .writeText(`${data.severity}: ${data.summary}\n${data.detail}`)
feb19220 163 .catch(err => Ext.Msg.alert(gettext('Error'), err));
f6710aac
TL
164 },
165 },
166 ],
167 },
168 ],
459b6c31
AL
169 listeners: {
170 itemdblclick: function(view, record, row, rowIdx, e) {
feb19220
TL
171 // inspired by Ext.grid.plugin.RowExpander, but for double click
172 let rowNode = view.getNode(rowIdx);
173 let normalRow = Ext.fly(rowNode);
459b6c31
AL
174
175 let collapsedCls = view.rowBodyFeature.rowCollapsedCls;
176
177 if (normalRow.hasCls(collapsedCls)) {
178 view.rowBodyFeature.rowExpander.toggleRow(rowIdx, record);
179 }
180 },
181 },
182 plugins: [
183 {
184 ptype: 'rowexpander',
185 expandOnDblClick: false,
186 rowBodyTpl: '<pre class="pve-ceph-warning-detail">{detail}</pre>',
187 },
188 ],
f6710aac
TL
189 },
190 ],
946730cd
DC
191 },
192 {
193 xtype: 'pveCephStatusDetail',
194 itemId: 'statusdetail',
9f7cbaf3
DC
195 plugins: 'responsive',
196 responsiveConfig: {
35279245 197 'width < 1600': {
27b91275 198 columnWidth: 1,
f6710aac 199 minHeight: 250,
9f7cbaf3 200 },
35279245 201 'width >= 1600': {
27b91275 202 columnWidth: 0.5,
f6710aac
TL
203 minHeight: 300,
204 },
9f7cbaf3 205 },
f6710aac 206 title: gettext('Status'),
946730cd 207 },
4ad4262d 208 {
4ad4262d 209 xtype: 'pveCephServices',
616d54de 210 title: gettext('Services'),
4ad4262d
DC
211 itemId: 'services',
212 plugins: 'responsive',
213 layout: {
214 type: 'hbox',
f6710aac 215 align: 'stretch',
4ad4262d
DC
216 },
217 responsiveConfig: {
35279245 218 'width < 1600': {
4ad4262d 219 columnWidth: 1,
f6710aac 220 minHeight: 200,
4ad4262d 221 },
35279245 222 'width >= 1600': {
4ad4262d 223 columnWidth: 0.5,
f6710aac
TL
224 minHeight: 200,
225 },
226 },
4ad4262d 227 },
946730cd
DC
228 {
229 xtype: 'panel',
230 title: gettext('Performance'),
9f7cbaf3
DC
231 columnWidth: 1,
232 bodyPadding: 5,
946730cd
DC
233 layout: {
234 type: 'hbox',
f6710aac 235 align: 'center',
946730cd
DC
236 },
237 items: [
238 {
62281115 239 xtype: 'container',
616d54de 240 flex: 1,
62281115
DC
241 items: [
242 {
243 xtype: 'proxmoxGauge',
244 itemId: 'space',
f6710aac 245 title: gettext('Usage'),
62281115
DC
246 },
247 {
248 flex: 1,
249 border: false,
250 },
251 {
252 xtype: 'container',
253 itemId: 'recovery',
254 hidden: true,
255 padding: 25,
256 items: [
257 {
62281115 258 xtype: 'pveRunningChart',
616d54de 259 itemId: 'recoverychart',
e767e1ec 260 title: gettext('Recovery') +'/ '+ gettext('Rebalance'),
62281115
DC
261 renderer: PVE.Utils.render_bandwidth,
262 height: 100,
263 },
264 {
265 xtype: 'progressbar',
266 itemId: 'recoveryprogress',
267 },
f6710aac 268 ],
62281115 269 },
f6710aac 270 ],
946730cd
DC
271 },
272 {
946730cd 273 xtype: 'container',
616d54de 274 flex: 2,
946730cd 275 defaults: {
9f7cbaf3 276 padding: 0,
f6710aac 277 height: 100,
946730cd
DC
278 },
279 items: [
280 {
946730cd 281 xtype: 'pveRunningChart',
616d54de 282 itemId: 'reads',
946730cd 283 title: gettext('Reads'),
f6710aac 284 renderer: PVE.Utils.render_bandwidth,
946730cd
DC
285 },
286 {
946730cd 287 xtype: 'pveRunningChart',
616d54de 288 itemId: 'writes',
946730cd 289 title: gettext('Writes'),
f6710aac 290 renderer: PVE.Utils.render_bandwidth,
946730cd 291 },
946730cd 292 {
946730cd 293 xtype: 'pveRunningChart',
616d54de 294 itemId: 'readiops',
8f8ec25d 295 title: 'IOPS: ' + gettext('Reads'),
f6710aac 296 renderer: Ext.util.Format.numberRenderer('0,000'),
946730cd
DC
297 },
298 {
946730cd 299 xtype: 'pveRunningChart',
616d54de 300 itemId: 'writeiops',
8f8ec25d 301 title: 'IOPS: ' + gettext('Writes'),
f6710aac 302 renderer: Ext.util.Format.numberRenderer('0,000'),
df503ff9 303 },
f6710aac
TL
304 ],
305 },
306 ],
307 },
946730cd 308 ],
bd39c945 309
946730cd
DC
310 updateAll: function(store, records, success) {
311 if (!success || records.length === 0) {
312 return;
313 }
bd39c945 314
946730cd
DC
315 var me = this;
316 var rec = records[0];
0bf3c581 317 me.status = rec.data;
bd39c945 318
946730cd 319 // add health panel
dfe6d184 320 me.down('#overallhealth').updateHealth(PVE.Utils.render_ceph_health(rec.data.health || {}));
b8febbcc 321 me.down('#warnings').updateHealth(rec.data.health || {}); // add errors to gridstore
bd39c945 322
4ad4262d
DC
323 me.getComponent('services').updateAll(me.metadata || {}, rec.data);
324
0bf3c581 325 me.getComponent('statusdetail').updateAll(me.metadata || {}, rec.data);
bd39c945 326
946730cd 327 // add performance data
df503ff9
TL
328 let pgmap = rec.data.pgmap;
329 let used = pgmap.bytes_used;
330 let total = pgmap.bytes_total;
bd39c945 331
946730cd 332 var text = Ext.String.format(gettext('{0} of {1}'),
1bd7bcdb
DC
333 Proxmox.Utils.render_size(used),
334 Proxmox.Utils.render_size(total),
946730cd 335 );
bd39c945 336
946730cd
DC
337 // update the usage widget
338 me.down('#space').updateValue(used/total, text);
bd39c945 339
df503ff9
TL
340 let readiops = pgmap.read_op_per_sec;
341 let writeiops = pgmap.write_op_per_sec;
342 let reads = pgmap.read_bytes_sec || 0;
343 let writes = pgmap.write_bytes_sec || 0;
bd39c945 344
946730cd
DC
345 // update the graphs
346 me.reads.addDataPoint(reads);
347 me.writes.addDataPoint(writes);
946730cd
DC
348 me.readiops.addDataPoint(readiops);
349 me.writeiops.addDataPoint(writeiops);
62281115
DC
350
351 let degraded = pgmap.degraded_objects || 0;
352 let misplaced = pgmap.misplaced_objects || 0;
353 let unfound = pgmap.unfound_objects || 0;
354 let unhealthy = degraded + unfound + misplaced;
355 // update recovery
356 if (pgmap.recovering_objects_per_sec !== undefined || unhealthy > 0) {
cb2013db
DC
357 let toRecoverObjects = pgmap.misplaced_total || pgmap.unfound_total || pgmap.degraded_total || 0;
358 if (toRecoverObjects === 0) {
10b00f3a
TL
359 return; // FIXME: unexpected return and leaves things possible visible when it shouldn't?
360 }
cb2013db 361 let recovered = toRecoverObjects - unhealthy || 0;
62281115 362 let speed = pgmap.recovering_bytes_per_sec || 0;
62281115 363
cb2013db 364 let recoveryRatio = recovered / toRecoverObjects;
10b00f3a 365 let txt = `${(recoveryRatio * 100).toFixed(2)}%`;
62281115 366 if (speed > 0) {
10b00f3a
TL
367 let obj_per_sec = speed / (4 * 1024 * 1024); // 4 MiB per Object
368 let duration = Proxmox.Utils.format_duration_human(unhealthy/obj_per_sec);
369 let speedTxt = PVE.Utils.render_bandwidth(speed);
62281115
DC
370 txt += ` (${speedTxt} - ${duration} left)`;
371 }
372
373 me.down('#recovery').setVisible(true);
10b00f3a 374 me.down('#recoveryprogress').updateValue(recoveryRatio);
62281115
DC
375 me.down('#recoveryprogress').updateText(txt);
376 me.down('#recoverychart').addDataPoint(speed);
377 } else {
378 me.down('#recovery').setVisible(false);
379 me.down('#recoverychart').addDataPoint(0);
380 }
946730cd
DC
381 },
382
946730cd
DC
383 initComponent: function() {
384 var me = this;
bd39c945 385
946730cd 386 var nodename = me.pveSelNode.data.node;
bd39c945 387
946730cd 388 me.callParent();
d2193664 389 var baseurl = '/api2/json' + (nodename ? '/nodes/' + nodename : '/cluster') + '/ceph';
0c7c0d6b 390 me.store = Ext.create('Proxmox.data.UpdateStore', {
2365c5c1 391 storeid: 'ceph-status-' + (nodename || 'cluster'),
946730cd
DC
392 interval: 5000,
393 proxy: {
56a353b9 394 type: 'proxmox',
f6710aac
TL
395 url: baseurl + '/status',
396 },
bd39c945
DM
397 });
398
7f58689d
DC
399 me.metadatastore = Ext.create('Proxmox.data.UpdateStore', {
400 storeid: 'ceph-metadata-' + (nodename || 'cluster'),
401 interval: 15*1000,
402 proxy: {
403 type: 'proxmox',
f6710aac
TL
404 url: '/api2/json/cluster/ceph/metadata',
405 },
7f58689d
DC
406 });
407
946730cd
DC
408 // save references for the updatefunction
409 me.iops = me.down('#iops');
410 me.readiops = me.down('#readiops');
411 me.writeiops = me.down('#writeiops');
412 me.reads = me.down('#reads');
413 me.writes = me.down('#writes');
414
13786fb0
TL
415 // manages the "install ceph?" overlay
416 PVE.Utils.monitor_ceph_installed(me, me.store, nodename);
4616a55b 417
946730cd 418 me.mon(me.store, 'load', me.updateAll, me);
7f58689d
DC
419 me.mon(me.metadatastore, 'load', function(store, records, success) {
420 if (!success || records.length < 1) {
421 return;
422 }
10b00f3a 423 me.metadata = records[0].data;
7f58689d 424
4ad4262d 425 // update services
10b00f3a 426 me.getComponent('services').updateAll(me.metadata, me.status || {});
4ad4262d 427
7f58689d 428 // update detailstatus panel
10b00f3a 429 me.getComponent('statusdetail').updateAll(me.metadata, me.status || {});
7f58689d 430
949a6609
DC
431 let maxversion = [];
432 let maxversiontext = "";
10b00f3a 433 for (const [_nodename, data] of Object.entries(me.metadata.node)) {
949a6609
DC
434 let version = data.version.parts;
435 if (PVE.Utils.compare_ceph_versions(version, maxversion) > 0) {
436 maxversion = version;
949a6609
DC
437 maxversiontext = data.version.str;
438 }
439 }
0beb2578 440 me.down('#versioninfo').setValue(maxversiontext);
7f58689d
DC
441 }, me);
442
946730cd 443 me.on('destroy', me.store.stopUpdate);
4ad4262d 444 me.on('destroy', me.metadatastore.stopUpdate);
946730cd 445 me.store.startUpdate();
4ad4262d 446 me.metadatastore.startUpdate();
f6710aac 447 },
946730cd 448
bd39c945 449});