This commit is contained in:
jhnine 2024-06-24 12:35:39 +08:00
parent f084bb4311
commit d3622e132e
5 changed files with 53 additions and 39 deletions

View File

@ -3,5 +3,5 @@ ENV = 'production'
# base api
VUE_APP_BASE_API = '/jcc-ks'
VUE_APP_PUBLIC_SOURCE_API = '/monitor'
VUE_APP_PUBLIC_SOURCE_API = ''

View File

@ -70,7 +70,8 @@ export function getEarthDetails(area) {
// 整体总负载 平均使用情况
export function getTotalAverage() {
return request({
url: '/jcc-schedule/api/v1/resource/getOverallMetrics',
url: '/pcm/v1/core/getScreenChart',
// url: '/jcc-schedule/api/v1/resource/getOverallMetrics',
method: 'get'
})
}

View File

@ -18,10 +18,10 @@ export default {
}
return {
day,
ramLoad: [2, 3, 4, 5, 6, 4, 5], //
cpuLoad: [1, 2, 3, 4, 5, 3, 4], // CPU
cpuAverage: [3, 4, 5, 3, 4, 3, 4], // cpu
ramAverage: [7, 6, 5, 4, 6, 5, 4] //
ramLoad: [], //
cpuLoad: [], // CPU
cpuAverage: [], // cpu
ramAverage: [] //
}
},
computed: {
@ -40,33 +40,38 @@ export default {
//
async getAllData() {
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'))
})
this.ramLoad = this.ramLoad.slice(0, 7)
// 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.cpuLoad = this.cpuLoad.slice(0, 7)
// 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.cpuAverage = this.cpuAverage.slice(0, 7)
// (%)
const ramAverage = data.find(item => item.metric_name === 'mem_avg_usage').data.result[0].values || []
ramAverage.forEach(element => {
this.ramAverage.push(((element[1] - 0) / 1024 / 1024 / 1024).toFixed(2))
})
this.ramAverage = this.ramAverage.slice(0, 7)
this.ramLoad = res.data.memoryLoad
this.ramAverage = res.data.memoryAvg
this.cpuLoad = res.data.cpuLoad
this.cpuAverage = res.data.cpuAvg
// 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'))
// })
// this.ramLoad = this.ramLoad.slice(0, 7)
// // 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.cpuLoad = this.cpuLoad.slice(0, 7)
// // 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.cpuAverage = this.cpuAverage.slice(0, 7)
// // (%)
// const ramAverage = data.find(item => item.metric_name === 'mem_avg_usage').data.result[0].values || []
// ramAverage.forEach(element => {
// this.ramAverage.push(((element[1] - 0) / 1024 / 1024 / 1024).toFixed(2))
// })
// this.ramAverage = this.ramAverage.slice(0, 7)
})
this.initCharts()
},

View File

@ -20,17 +20,25 @@
</template>
<script>
import { getStorageData } from '@/api/container/monitorSelect'
export default {
props: {
data: {
type: Object,
default: () => ({})
}
},
data() {
return {
storageData: {}
}
},
mounted() {
getStorageData().then(e => {
this.storageData = e
})
watch: {
data: {
handler(newValue, oldValue) {
this.storageData = newValue
},
deep: true
}
}
}
</script>

View File

@ -44,7 +44,7 @@
</div>
<div class="right_3">
<div class="title"><p>存储资源用量</p></div>
<StorageResourceUsage />
<StorageResourceUsage :data="powerData" />
</div>
</div>
</div>