]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
81634fe950344a1a73169c44eb929122540cda18
[ceph.git] /
1 import { Component, OnDestroy, OnInit } from '@angular/core';
2
3 import _ from 'lodash';
4 import { Subscription } from 'rxjs';
5
6 import { Permissions } from '~/app/shared/models/permissions';
7 import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
8 import { RefreshIntervalService } from '~/app/shared/services/refresh-interval.service';
9 import { RgwDaemonService } from '~/app/shared/api/rgw-daemon.service';
10 import { RgwRealmService } from '~/app/shared/api/rgw-realm.service';
11 import { RgwZoneService } from '~/app/shared/api/rgw-zone.service';
12 import { RgwZonegroupService } from '~/app/shared/api/rgw-zonegroup.service';
13 import { RgwBucketService } from '~/app/shared/api/rgw-bucket.service';
14 import { RgwUserService } from '~/app/shared/api/rgw-user.service';
15 import { PrometheusService } from '~/app/shared/api/prometheus.service';
16 import { RgwPromqls as queries } from '~/app/shared/enum/dashboard-promqls.enum';
17 import { HealthService } from '~/app/shared/api/health.service';
18
19 @Component({
20   selector: 'cd-rgw-overview-dashboard',
21   templateUrl: './rgw-overview-dashboard.component.html',
22   styleUrls: ['./rgw-overview-dashboard.component.scss']
23 })
24 export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
25   interval = new Subscription();
26   permissions: Permissions;
27   rgwDaemonCount = 0;
28   rgwRealmCount = 0;
29   rgwZonegroupCount = 0;
30   rgwZoneCount = 0;
31   rgwBucketCount = 0;
32   objectCount = 0;
33   UserCount = 0;
34   totalPoolUsedBytes = 0;
35   averageObjectSize = 0;
36   realmData: any;
37   daemonSub: Subscription;
38   realmSub: Subscription;
39   ZonegroupSub: Subscription;
40   ZoneSUb: Subscription;
41   UserSub: Subscription;
42   HealthSub: Subscription;
43   BucketSub: Subscription;
44   queriesResults: any = {
45     RGW_REQUEST_PER_SECOND: '',
46     BANDWIDTH: '',
47     AVG_GET_LATENCY: '',
48     AVG_PUT_LATENCY: ''
49   };
50   timerGetPrometheusDataSub: Subscription;
51
52   constructor(
53     private authStorageService: AuthStorageService,
54     private healthService: HealthService,
55     private refreshIntervalService: RefreshIntervalService,
56     private rgwDaemonService: RgwDaemonService,
57     private rgwRealmService: RgwRealmService,
58     private rgwZonegroupService: RgwZonegroupService,
59     private rgwZoneService: RgwZoneService,
60     private rgwBucketService: RgwBucketService,
61     private rgwUserService: RgwUserService,
62     private prometheusService: PrometheusService
63   ) {
64     this.permissions = this.authStorageService.getPermissions();
65   }
66
67   ngOnInit() {
68     this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
69       this.daemonSub = this.rgwDaemonService.list().subscribe((data: any) => {
70         this.rgwDaemonCount = data.length;
71       });
72       this.BucketSub = this.rgwBucketService.list().subscribe((data: any) => {
73         this.rgwBucketCount = data.length;
74       });
75       this.UserSub = this.rgwUserService.list().subscribe((data: any) => {
76         this.UserCount = data.length;
77       });
78       this.HealthSub = this.healthService.getClusterCapacity().subscribe((data: any) => {
79         this.objectCount = data['total_objects'];
80         this.totalPoolUsedBytes = data['total_pool_bytes_used'];
81         this.averageObjectSize = data['average_object_size'];
82       });
83     });
84     this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
85       this.rgwRealmCount = data['realms'].length;
86     });
87     this.ZonegroupSub = this.rgwZonegroupService.list().subscribe((data: any) => {
88       this.rgwZonegroupCount = data['zonegroups'].length;
89     });
90     this.ZoneSUb = this.rgwZoneService.list().subscribe((data: any) => {
91       this.rgwZoneCount = data['zones'].length;
92     });
93     this.getPrometheusData(this.prometheusService.lastHourDateObject);
94   }
95
96   ngOnDestroy() {
97     this.interval.unsubscribe();
98     this.daemonSub.unsubscribe();
99     this.realmSub.unsubscribe();
100     this.ZonegroupSub.unsubscribe();
101     this.ZoneSUb.unsubscribe();
102     this.BucketSub.unsubscribe();
103     this.UserSub.unsubscribe();
104     this.HealthSub.unsubscribe();
105     if (this.timerGetPrometheusDataSub) {
106       this.timerGetPrometheusDataSub.unsubscribe();
107     }
108   }
109
110   getPrometheusData(selectedTime: any) {
111     this.queriesResults = this.prometheusService.getPrometheusQueriesData(
112       selectedTime,
113       queries,
114       this.queriesResults,
115       true
116     );
117   }
118 }