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 # base api
VUE_APP_BASE_API = '/jcc-ks' 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() { export function getTotalAverage() {
return request({ return request({
url: '/jcc-schedule/api/v1/resource/getOverallMetrics', url: '/pcm/v1/core/getScreenChart',
// url: '/jcc-schedule/api/v1/resource/getOverallMetrics',
method: 'get' method: 'get'
}) })
} }

View File

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

View File

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

View File

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