1 import { Component, OnDestroy, OnInit } from '@angular/core';
3 import _ from 'lodash';
4 import { Subscription } from 'rxjs';
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';
20 selector: 'cd-rgw-overview-dashboard',
21 templateUrl: './rgw-overview-dashboard.component.html',
22 styleUrls: ['./rgw-overview-dashboard.component.scss']
24 export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
25 interval = new Subscription();
26 permissions: Permissions;
29 rgwZonegroupCount = 0;
34 totalPoolUsedBytes = 0;
35 averageObjectSize = 0;
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: '',
50 timerGetPrometheusDataSub: Subscription;
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
64 this.permissions = this.authStorageService.getPermissions();
68 this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
69 this.daemonSub = this.rgwDaemonService.list().subscribe((data: any) => {
70 this.rgwDaemonCount = data.length;
72 this.BucketSub = this.rgwBucketService.list().subscribe((data: any) => {
73 this.rgwBucketCount = data.length;
75 this.UserSub = this.rgwUserService.list().subscribe((data: any) => {
76 this.UserCount = data.length;
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'];
84 this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
85 this.rgwRealmCount = data['realms'].length;
87 this.ZonegroupSub = this.rgwZonegroupService.list().subscribe((data: any) => {
88 this.rgwZonegroupCount = data['zonegroups'].length;
90 this.ZoneSUb = this.rgwZoneService.list().subscribe((data: any) => {
91 this.rgwZoneCount = data['zones'].length;
93 this.getPrometheusData(this.prometheusService.lastHourDateObject);
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();
110 getPrometheusData(selectedTime: any) {
111 this.queriesResults = this.prometheusService.getPrometheusQueriesData(