diff --git a/src/views/abnormalAlarm/serverMonitor/instances/details.vue b/src/views/abnormalAlarm/serverMonitor/instances/details.vue index db1a9dc..82beff5 100644 --- a/src/views/abnormalAlarm/serverMonitor/instances/details.vue +++ b/src/views/abnormalAlarm/serverMonitor/instances/details.vue @@ -320,9 +320,15 @@ @@ -414,6 +420,7 @@ import BoxTitle from '../../components/boxTitle.vue' import infiniteScroll from 'vue-infinite-scroll' import { getAction, postAction, httpAction, deleteAction } from '@/api/manage' import * as echarts from 'echarts' +import dateFormat from '@/components/jeecg/JEasyCron/format-date' export default { directives: { infiniteScroll }, components: { @@ -443,9 +450,12 @@ export default { guageCpu: null, guageMemory: null, guageLoads: null, - areaCpu: null, currId: '', detailInfo: {}, + currItemId: '', + // cpu + areaCpu: null, + cpuData: {}, } }, mounted() { @@ -458,11 +468,14 @@ export default { if (this.$route.query.serverId) { this.currId = this.$route.query.serverId this.currIndex = this.dataSource.findIndex((item) => item.hostId === this.currId) + this.currItemId = this.dataSource.find((item) => item.hostId === this.currId).cpuUsedItemId } else { this.currId = this.dataSource[0].hostId + this.currItemId = this.dataSource[0].cpuUsedItemId this.currIndex = 0 } this.getBasiclnfo(this.currId) + this.getCpuUtilizationData() } else { this.$message.warning('This operation fails. Contact your system administrator') } @@ -480,7 +493,6 @@ export default { setTimeout(() => { this.drawTimeline() this.drawGuageLoads() - this.drawAreaCpu() }, 0) }) }, @@ -499,6 +511,30 @@ export default { } }) }, + //CPU utilization + getCpuUtilizationData() { + let params = { + // itemId: this.currItemId, + itemId: '37550', + itemType: 0, + start: `${dateFormat(new Date(), 'yyyy-MM-dd')} 00:00:00`, + end: dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss'), + } + getAction('/systemMonitor/queryItemHistoryData', params).then((res) => { + const arr = res.result.map((x) => x.value) + this.cpuData.max = Math.max(...arr) * 100 + this.cpuData.min = Math.min(...arr) * 100 + let sum = arr.reduce((tatal, num) => tatal + num, 0) + this.cpuData.avg = (sum / arr.length).toFixed(2) * 100 + this.cpuData.xData = res.result.map((item) => { + return dateFormat(new Date(item.date), 'hh:mm') + }) + this.cpuData.yData = res.result.map((item) => { + return item.value * 100 + }) + this.drawAreaCpu() + }) + }, getSysServer(callBack) { this.loading = true let params = { @@ -1010,7 +1046,7 @@ export default { axisLabel: { color: 'rgba(173, 230, 238, 1)', }, - data: date, + data: this.cpuData.xData, }, yAxis: { type: 'value', @@ -1042,7 +1078,7 @@ export default { color: '#10b3d6', }, }, - data: data, + data: this.cpuData.yData, }, ], } diff --git a/src/views/abnormalAlarm/serverMonitor/instances/serviceProcess.vue b/src/views/abnormalAlarm/serverMonitor/instances/serviceProcess.vue index c81e8c5..198525d 100644 --- a/src/views/abnormalAlarm/serverMonitor/instances/serviceProcess.vue +++ b/src/views/abnormalAlarm/serverMonitor/instances/serviceProcess.vue @@ -1,16 +1,17 @@