拓扑图 接口修改

This commit is contained in:
jhnine 2022-11-17 10:21:17 +08:00
parent e8d82b2e4c
commit 75cd629114
1 changed files with 25 additions and 55 deletions

View File

@ -61,7 +61,7 @@ import Navbar from '@/layout/components/Navbar'
import List from '@/components/list'
import * as echarts from 'echarts'
import { getClusterUserRate } from '@/api/container/overview'
import { getRamLoad, getCpuAllload, getCpuAverage, getRamAverage } from '@/api/top-menu/TotalNum'
import { getTotalAverage } from '@/api/top-menu/TotalNum'
import { getProjectNamespaceList, getMapDomainList, getNamespaceDescribe, getResourceCount } from '@/api/dispatching-center/dispatchingCenter'
import moment from 'moment'
import variables from '@/styles/variables.js'
@ -309,64 +309,34 @@ export default {
},
//
async getAllData() {
const a = moment().subtract(1, 'days').endOf('day').unix()
const b = moment().subtract(7, 'days').endOf('day').unix()
// GB
await getRamLoad(b, a, 86400).then(res => {
const demo = res.data?.result[0]?.values || []
const demo1 = this.day.map(n => {
const filters = demo.filter(m => m[0] === n[0])
if (filters.length > 0) {
return (((Number(filters[0][1]) / 1024 / 1024 / 1024))).toFixed(2)
} else {
return 0
}
await getTotalAverage().then(res => {
const data = res.data
// GB
const ramData = data.find(item => item.metric_name === 'mem_total_usage').data.result[0].values || []
ramData.forEach(element => {
this.ramLoad.push(((element[1] - 0) / 1024 / 1024 / 1024).toFixed(2))
// this.date.push(moment(element[0] * 1000).format('MM/DD'))
})
// CPU Core
const cpuLoad = data.find(item => item.metric_name === 'cpu_total_usage').data.result[0].values || []
cpuLoad.forEach(element => {
this.cpuLoad.push(((element[1] - 0)).toFixed(2))
})
this.ramLoad = demo1
})
// CPU Core
await getCpuAllload(b, a).then(res => {
const demo = res.data?.result[0]?.values || []
let demo1 = []
demo1 = this.day.map((n) => {
let value = 0
demo.forEach(element => {
// 90015
if (element[0] > (n[0] - 86400) && element[0] <= n[0]) {
value += Number(element[1])
}
})
return value.toFixed(2)
await getTotalAverage().then(res => {
const data = res.data
// cpu (%)
const cpuData = data.find(item => item.metric_name === 'cpu_avg_usage').data.result[0].values || []
cpuData.forEach(element => {
this.cpuAverage.push((element[1] - 0).toFixed(2))
// this.date.push(moment(element[0] * 1000).format('MM/DD'))
})
this.cpuLoad = demo1
})
// cpu (%)
await getCpuAverage(b, a, 86400).then(res => {
const demo = res.data?.result[0]?.values || []
const demo1 = this.day.map(n => {
const filters = demo.filter(m => m[0] === n[0])
if (filters.length > 0) {
return Number(filters[0][1]).toFixed(2)
} else {
return 0
}
// (%)
const ramData = data.find(item => item.metric_name === 'mem_avg_usage').data.result[0].values || []
ramData.forEach(element => {
this.ramAverage.push(((element[1] - 0) / 1024 / 1024 / 1024).toFixed(2))
})
this.cpuAverage = demo1
})
// (%)
await getRamAverage(b, a, 86400).then(res => {
const demo = res.data?.result[0]?.values || []
const demo1 = this.day.map(n => {
const filters = demo.filter(m => m[0] === n[0])
if (filters.length > 0) {
return Number(filters[0][1]).toFixed(2)
} else {
return 0
}
})
this.ramAverage = demo1
})
this.initCharts()
},
@ -415,7 +385,7 @@ export default {
{
name: '',
axisLabel: {
formatter: '{value} %'
formatter: '{value}'
},
splitLine: {
lineStyle: {