mirror of https://gitee.com/xiaonuobase/snowy
【优化】系统监控页面加载优化
parent
b2948f7966
commit
545cced87c
|
@ -21,5 +21,9 @@ export default {
|
|||
// 获取服务器监控信息
|
||||
monitorServerInfo(data) {
|
||||
return request('serverInfo', data, 'get')
|
||||
},
|
||||
// 获取服务器网络情况
|
||||
monitorNetworkInfo(data) {
|
||||
return request('networkInfo', data, 'get')
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
})
|
||||
// 监听错误事件
|
||||
source.addEventListener('error', (e) => {
|
||||
console.error('发生错误,消息事实获取已断开与服务器的连接')
|
||||
console.error('发生错误,消息实时获取已断开与服务器的连接')
|
||||
source.close()
|
||||
})
|
||||
} else {
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,4 +29,12 @@ public interface DevMonitorService {
|
|||
* @date 2022/9/1 16:02
|
||||
*/
|
||||
DevMonitorServerResult serverInfo();
|
||||
|
||||
/**
|
||||
* 获取服务器网络情况
|
||||
*
|
||||
* @author diantu
|
||||
* @date 2023/7/27
|
||||
*/
|
||||
DevMonitorServerResult networkInfo();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue