Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {Component, OnInit} from '@angular/core';
import {CommonService} from '../../../shared/common/common.service';
import {ActivatedRoute} from '@angular/router';
import {NzMessageService} from 'ng-zorro-antd';
import {OverAllService} from '../../overAll.service';
import {AlarmService} from '../../../alarm/alarm.service';
import {AnalysisService} from '../../../analysis/analysis.service';
@Component({
selector: 'smart-database',
templateUrl: './database.component.html',
styles: []
})
export class DatabaseComponent implements OnInit {
hostId;
charTrendOption;
chartDatabaseOption;
isFlowLoading = false;
isDatabaseLoading = false;
databaseList; //数据库列表
databaseType; // 选择的数据库类型
databaseDetail; //指标列表
eventList; //告警列表
indexDetail; //数据库详情指标
obj = {
groupid: null,
startTime: null,
endTime: null,
priorityName: null,
};
timeTypeFlow = '4';
flowObj = {
startTime: null,
endTime: null
};
timeTypeDatabase = '0';
databaseObj = {
startTime: null,
endTime: null
};
constructor(private commonSer: CommonService, private routerInfo: ActivatedRoute,
private message: NzMessageService, private overAllSer: OverAllService,
private alarmSer: AlarmService, private analysisSer: AnalysisService) {
this.routerInfo.queryParams.subscribe(queryParams => {
this.hostId = queryParams.hostId;
this.overAllSer.findDetailed(this.hostId).subscribe(
(res) => {
let data = res.data[0];
}
);
});
}
ngOnInit() {
this.findDatabase();
this.findIndexDetail();
this.eventFind();
}
//查询所有数据库类型
findDatabase() {
this.overAllSer.findAllDatabaseByHost(this.hostId).subscribe(
(res) => {
if (res.errCode == 10000) {
if (res.data.length > 0) {
this.databaseList = res.data;
this.databaseType = this.databaseList[0].type;
this.findTarget();
}
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
}
}
);
}
//指标列表
findTarget() {
const data = {
'hostid': this.hostId,
'databaseType': this.databaseType
};
this.overAllSer.findDatabaseDetailByHost(data).subscribe(
(res) => {
this.databaseDetail = res.data;
}
);
}
//数据库详情指标
findIndexDetail() {
const data = {
hostid: this.hostId
};
this.overAllSer.findIndexDetail(data).subscribe(
(res) => {
this.indexDetail = res.data;
}
);
}
//当前告警
eventFind() {
const data = {
pageCount: 10,
pageNum: 1,
obj: {
isWaring: 'yes',
hostid: this.hostId
}
};
this.alarmSer.eventFind(data).subscribe(
(res) => {
this.eventList = res.data.data;
}
);
}
this.flowObj = this.commonSer.getTimeByType(this.timeTypeFlow);
this.getAlarmTrend();
}
//告警总数趋势
getAlarmTrend() {
const data = {
hostid: this.hostId,
startTime: this.flowObj.startTime,
endTime: this.flowObj.endTime,
};
this.overAllSer.waringTrendByHost(data).subscribe(
(res) => {
if (res.errCode == 10000) {
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
}
this.isFlowLoading = false;
}
);
}
//设置告警趋势echarts图表
setAlarmTrend(data) {
this.charTrendOption = {
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
},
legend: {
textStyle: {color: '#ffffff'},
data: ['严重', '告警']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
data: data.map((e) => {
return e.date;
})
}
],
yAxis: [
{
type: 'value',
minInterval: 1,
axisLabel: {
show: true,
interval: 'auto',
formatter: '{value} 个'
},
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
boundaryGap: [0, 0.1],
}
],
series: [
{
name: '严重',
type: 'bar',
stack: '严重',
itemStyle: {
normal: {
color: '#e96545'
}
},
data: data.map(e => {
return e.errorcount;
})
},
{
name: '告警',
type: 'bar',
stack: '告警',
itemStyle: {
normal: {
color: '#eede85'
}
},
data: data.map(e => {
return e.waringcount;
})
}
]
};
}
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
this.databaseObj = this.commonSer.getTimeByType(this.timeTypeDatabase);
this.databaseChart();
}
//数据库图表
databaseChart() {
const data = {
hostid: this.hostId,
startTime: this.databaseObj.startTime,
endTime: this.databaseObj.endTime,
};
this.overAllSer.findChartData(data).subscribe(
(res) => {
if (res.data.list) {
this.setDatabaseChart(res.data);
}
this.isDatabaseLoading = false;
}
);
}
//设置数据库图表
setDatabaseChart(data) {
let arr = [];
data.databaseType.forEach(e => {
const obj = {
name: e,
stack: '数据库',
type: 'line',
itemStyle: {
normal: {
lineStyle: {
color: '#2cfef7'
}
}
},
data: [],
};
data.list.forEach(f => {
obj.data.push(f[e]);
});
arr.push(obj);
});
this.chartDatabaseOption = {
xAxis: {
type: 'category',
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
data: data.list.map(e => {
return e.time;
})
},
yAxis: {
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
type: 'value'
},
series: arr
};
}
}