【优化】系统监控页面加载优化

pull/145/head
diant 2023-07-27 14:52:30 +08:00
parent b2948f7966
commit 545cced87c
6 changed files with 87 additions and 30 deletions

View File

@ -21,5 +21,9 @@ export default {
// 获取服务器监控信息
monitorServerInfo(data) {
return request('serverInfo', data, 'get')
},
// 获取服务器网络情况
monitorNetworkInfo(data) {
return request('networkInfo', data, 'get')
}
}

View File

@ -101,7 +101,7 @@
})
//
source.addEventListener('error', (e) => {
console.error('发生错误,消息实获取已断开与服务器的连接')
console.error('发生错误,消息获取已断开与服务器的连接')
source.close()
})
} else {

View File

@ -58,27 +58,34 @@
</a-col>
<a-col :span="6">
<a-card title="网络信息" :bordered="false" class="monitor-center-row-col-card">
<a-statistic
title="上行速率"
:value="devMonitorNetworkInfo.upLinkRate"
:precision="2"
:value-style="{ color: '#3f8600' }"
>
<template #prefix>
<arrow-up-outlined />
</template>
</a-statistic>
<a-statistic
class="mt-4"
title="下行速率"
:value="devMonitorNetworkInfo.downLinkRate"
:precision="2"
:value-style="{ color: '#cf1322' }"
>
<template #prefix>
<arrow-down-outlined />
</template>
</a-statistic>
<template #extra>
<a-button title="测速" :loading="networkSpinning" @click="getMonitorNetworkInfo">
<template #icon><UiwDashboard /></template>
</a-button>
</template>
<a-spin :spinning="networkSpinning">
<a-statistic
title="上行速率"
:value="devMonitorNetworkInfo.upLinkRate"
:precision="2"
:value-style="{ color: '#3f8600' }"
>
<template #prefix>
<arrow-up-outlined />
</template>
</a-statistic>
<a-statistic
class="mt-4"
title="下行速率"
:value="devMonitorNetworkInfo.downLinkRate"
:precision="2"
:value-style="{ color: '#cf1322' }"
>
<template #prefix>
<arrow-down-outlined />
</template>
</a-statistic>
</a-spin>
</a-card>
</a-col>
</a-row>
@ -139,6 +146,7 @@
import { onMounted } from 'vue'
import monitorApi from '@/api/dev/monitorApi'
const spinning = ref(false)
const networkSpinning = ref(false)
// CPU
const devMonitorCpuInfo = ref({})
//
@ -154,21 +162,31 @@
onMounted(() => {
getMonitorServerInfo()
getMonitorNetworkInfo()
})
const getMonitorServerInfo = () => {
spinning.value = true
monitorApi.monitorServerInfo().then((data) => {
spinning.value = false
networkSpinning.value = true
devMonitorCpuInfo.value = data.devMonitorCpuInfo
devMonitorMemoryInfo.value = data.devMonitorMemoryInfo
devMonitorStorageInfo.value = data.devMonitorStorageInfo
devMonitorNetworkInfo.value = data.devMonitorNetworkInfo
devMonitorServerInfo.value = data.devMonitorServerInfo
devMonitorJvmInfo.value = data.devMonitorJvmInfo
})
}
const getMonitorNetworkInfo = () => {
networkSpinning.value = true
networkSpinning.value = spinning.value ? false : networkSpinning.value
monitorApi.monitorNetworkInfo().then((data) => {
networkSpinning.value = false
devMonitorNetworkInfo.value = data.devMonitorNetworkInfo
})
}
// 30绿30-80 80
const getProgressColor = (value) => {
const values = Number(value)
@ -186,4 +204,7 @@
.monitor-center-row-col-card {
text-align: center;
}
:deep(.ant-card-extra) {
padding: 8px 0!important;
}
</style>

View File

@ -52,4 +52,17 @@ public class DevMonitorController {
public CommonResult<DevMonitorServerResult> serverInfo() {
return CommonResult.data(devMonitorService.serverInfo());
}
/**
*
*
* @author diantu
* @date 2023/7/27
*/
@ApiOperationSupport(order = 2)
@ApiOperation("获取服务器网络情况")
@GetMapping("/dev/monitor/networkInfo")
public CommonResult<DevMonitorServerResult> networkInfo() {
return CommonResult.data(devMonitorService.networkInfo());
}
}

View File

@ -29,4 +29,12 @@ public interface DevMonitorService {
* @date 2022/9/1 16:02
*/
DevMonitorServerResult serverInfo();
/**
*
*
* @author diantu
* @date 2023/7/27
*/
DevMonitorServerResult networkInfo();
}

View File

@ -121,13 +121,6 @@ public class DevMonitorServiceImpl implements DevMonitorService {
devMonitorStorageInfo.setStorageUseRate(NumberUtil.mul(NumberUtil.div(storageUsed.doubleValue(), storageTotal.doubleValue(), 4), 100));
devMonitorServerResult.setDevMonitorStorageInfo(devMonitorStorageInfo);
// 网络信息
DevMonitorServerResult.DevMonitorNetworkInfo devMonitorNetworkInfo = new DevMonitorServerResult.DevMonitorNetworkInfo();
Map<String, String> networkUpRate = CommonNetWorkInfoUtil.getNetworkUpRate();
devMonitorNetworkInfo.setUpLinkRate(networkUpRate.get("UP"));
devMonitorNetworkInfo.setDownLinkRate(networkUpRate.get("DOWN"));
devMonitorServerResult.setDevMonitorNetworkInfo(devMonitorNetworkInfo);
// 服务器信息
OsInfo osInfo = SystemUtil.getOsInfo();
DevMonitorServerResult.DevMonitorServerInfo devMonitorServerInfo = new DevMonitorServerResult.DevMonitorServerInfo();
@ -160,4 +153,22 @@ public class DevMonitorServiceImpl implements DevMonitorService {
devMonitorServerResult.setDevMonitorJvmInfo(devMonitorJvmInfo);
return devMonitorServerResult;
}
/**
*
*
* @author diantu
* @date 2023/7/27
*/
@Override
public DevMonitorServerResult networkInfo(){
DevMonitorServerResult devMonitorServerResult = new DevMonitorServerResult();
// 网络信息
DevMonitorServerResult.DevMonitorNetworkInfo devMonitorNetworkInfo = new DevMonitorServerResult.DevMonitorNetworkInfo();
Map<String, String> networkUpRate = CommonNetWorkInfoUtil.getNetworkUpRate();
devMonitorNetworkInfo.setUpLinkRate(networkUpRate.get("UP"));
devMonitorNetworkInfo.setDownLinkRate(networkUpRate.get("DOWN"));
devMonitorServerResult.setDevMonitorNetworkInfo(devMonitorNetworkInfo);
return devMonitorServerResult;
}
}