forked from JointCloud/JCC-RIP
拓扑图 接口修改
This commit is contained in:
parent
e8d82b2e4c
commit
75cd629114
|
@ -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 => {
|
||||
// 将每天的数据相加 时间间隔900(15分钟查一次) 累加为一天的数据
|
||||
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: {
|
||||
|
|
Loading…
Reference in New Issue