]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.ts
import 15.2.4
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / monitor / monitor.component.ts
1 import { Component } from '@angular/core';
2
3 import { I18n } from '@ngx-translate/i18n-polyfill';
4 import * as _ from 'lodash';
5
6 import { MonitorService } from '../../../shared/api/monitor.service';
7 import { CellTemplate } from '../../../shared/enum/cell-template.enum';
8
9 @Component({
10 selector: 'cd-monitor',
11 templateUrl: './monitor.component.html',
12 styleUrls: ['./monitor.component.scss']
13 })
14 export class MonitorComponent {
15 mon_status: any;
16 inQuorum: any;
17 notInQuorum: any;
18
19 interval: any;
20
21 constructor(private monitorService: MonitorService, private i18n: I18n) {
22 this.inQuorum = {
23 columns: [
24 { prop: 'name', name: this.i18n('Name'), cellTransformation: CellTemplate.routerLink },
25 { prop: 'rank', name: this.i18n('Rank') },
26 { prop: 'public_addr', name: this.i18n('Public Address') },
27 {
28 prop: 'cdOpenSessions',
29 name: this.i18n('Open Sessions'),
30 cellTransformation: CellTemplate.sparkline,
31 comparator: (dataA: any, dataB: any) => {
32 // We get the last value of time series to compare:
33 const lastValueA = _.last(dataA);
34 const lastValueB = _.last(dataB);
35
36 if (!lastValueA || !lastValueB || lastValueA === lastValueB) {
37 return 0;
38 }
39
40 return lastValueA > lastValueB ? 1 : -1;
41 }
42 }
43 ]
44 };
45
46 this.notInQuorum = {
47 columns: [
48 { prop: 'name', name: this.i18n('Name'), cellTransformation: CellTemplate.routerLink },
49 { prop: 'rank', name: this.i18n('Rank') },
50 { prop: 'public_addr', name: this.i18n('Public Address') }
51 ]
52 };
53 }
54
55 refresh() {
56 this.monitorService.getMonitor().subscribe((data: any) => {
57 data.in_quorum.map((row: any) => {
58 row.cdOpenSessions = row.stats.num_sessions.map((i: string) => i[1]);
59 row.cdLink = '/perf_counters/mon/' + row.name;
60 row.cdParams = { fromLink: '/monitor' };
61 return row;
62 });
63
64 data.out_quorum.map((row: any) => {
65 row.cdLink = '/perf_counters/mon/' + row.name;
66 row.cdParams = { fromLink: '/monitor' };
67 return row;
68 });
69
70 this.inQuorum.data = [...data.in_quorum];
71 this.notInQuorum.data = [...data.out_quorum];
72 this.mon_status = data.mon_status;
73 });
74 }
75 }