feat 插件端新增虚拟内存和交互内存监控趋势

This commit is contained in:
bwcx_jzy 2023-03-03 15:44:54 +08:00
parent 7c858c311f
commit f815d46fd8
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
6 changed files with 28 additions and 6 deletions

View File

@ -92,6 +92,9 @@ public class OshiUtils {
jsonObject.put("osCpuCores", processor.getLogicalProcessorCount());
GlobalMemory globalMemory = OshiUtil.getMemory();
jsonObject.put("osMoneyTotal", globalMemory.getTotal());
VirtualMemory virtualMemory = globalMemory.getVirtualMemory();
jsonObject.put("osSwapTotal", virtualMemory.getSwapTotal());
jsonObject.put("osVirtualMax", virtualMemory.getVirtualMax());
double[] systemLoadAverage = processor.getSystemLoadAverage(3);
jsonObject.put("osLoadAverage", systemLoadAverage);
FileSystem fileSystem = os.getFileSystem();
@ -116,8 +119,14 @@ public class OshiUtils {
GlobalMemory globalMemory = OshiUtil.getMemory();
jsonObject.put("memory", NumberUtil.div(globalMemory.getTotal() - globalMemory.getAvailable(), globalMemory.getTotal(), 2) * 100);
VirtualMemory virtualMemory = globalMemory.getVirtualMemory();
jsonObject.put("swapMemory", NumberUtil.div(virtualMemory.getSwapUsed(), virtualMemory.getSwapTotal(), 2) * 100);
jsonObject.put("virtualMemory", NumberUtil.div(virtualMemory.getVirtualInUse(), virtualMemory.getVirtualMax(), 2) * 100);
long swapTotal = virtualMemory.getSwapTotal();
if (swapTotal > 0) {
jsonObject.put("swapMemory", NumberUtil.div(virtualMemory.getSwapUsed(), swapTotal, 2) * 100);
}
long virtualMax = virtualMemory.getVirtualMax();
if (virtualMax > 0) {
jsonObject.put("virtualMemory", NumberUtil.div(virtualMemory.getVirtualInUse(), virtualMax, 2) * 100);
}
//
FileSystem fileSystem = OshiUtil.getOs().getFileSystem();
List<OSFileStore> fileStores = fileSystem.getFileStores();

View File

@ -82,6 +82,14 @@ public class MachineNodeModel extends BaseGroupNameModel implements INodeInfo {
* 总内存
*/
private Long osMoneyTotal;
/**
* 交互总内存
*/
private Long osSwapTotal;
/**
* 虚拟总内存
*/
private Long osVirtualMax;
/**
* 硬盘总大小
*/

View File

@ -293,6 +293,8 @@ public class MachineNodeServer extends BaseDbService<MachineNodeModel> implement
machineNodeModel.setOsCpuIdentifierName(jsonObject.getString("osCpuIdentifierName"));
machineNodeModel.setOsCpuCores(jsonObject.getInteger("osCpuCores"));
machineNodeModel.setOsMoneyTotal(jsonObject.getLong("osMoneyTotal"));
machineNodeModel.setOsSwapTotal(jsonObject.getLong("osSwapTotal"));
machineNodeModel.setOsVirtualMax(jsonObject.getLong("osVirtualMax"));
machineNodeModel.setOsLoadAverage(CollUtil.join(jsonObject.getList("osLoadAverage", Double.class), StrUtil.COMMA));
machineNodeModel.setOsFileStoreTotal(jsonObject.getLong("osFileStoreTotal"));
});

View File

@ -20,3 +20,5 @@ DROP-TABLE,SYSTEMMONITORLOG,
ADD,MACHINE_NODE_INFO,installId,String,50,,机器安装 id
ADD,MACHINE_NODE_STAT_LOG,occupySwapMemory,Double,,,交互内存
ADD,MACHINE_NODE_STAT_LOG,occupyVirtualMemory,Double,,,虚拟内存
ADD,MACHINE_NODE_INFO,osSwapTotal,Long,,,虚拟总内存
ADD,MACHINE_NODE_INFO,osVirtualMax,Long,,,交互总内存

1 alterType,tableName,name,type,len,defaultValue,comment,notNull
20 ADD,MACHINE_NODE_INFO,installId,String,50,,机器安装 id
21 ADD,MACHINE_NODE_STAT_LOG,occupySwapMemory,Double,,,交互内存
22 ADD,MACHINE_NODE_STAT_LOG,occupyVirtualMemory,Double,,,虚拟内存
23 ADD,MACHINE_NODE_INFO,osSwapTotal,Long,,,虚拟总内存
24 ADD,MACHINE_NODE_INFO,osVirtualMax,Long,,,交互总内存

View File

@ -121,8 +121,8 @@ export function generateNodeTopChart(data) {
cpuItem.data.push(parseFloat(item.occupyCpu));
diskItem.data.push(parseFloat(item.occupyDisk));
memoryItem.data.push(parseFloat(item.occupyMemory));
swapMemory.data.push(parseFloat(item.occupySwapMemory || -1));
virtualMemory.data.push(parseFloat(item.occupyVirtualMemory || -1));
swapMemory.data.push(parseFloat(item.occupySwapMemory || -0.1));
virtualMemory.data.push(parseFloat(item.occupyVirtualMemory || -0.1));
scales.push(parseTime(item.monitorTime));
}

View File

@ -49,6 +49,8 @@
</a-descriptions-item>
<a-descriptions-item label="CPU数">{{ machineInfo && machineInfo.osCpuCores }} </a-descriptions-item>
<a-descriptions-item label="内存">{{ renderSize(machineInfo && machineInfo.osMoneyTotal) }} </a-descriptions-item>
<a-descriptions-item label="虚拟内存">{{ renderSize(machineInfo && machineInfo.osVirtualMax) }} </a-descriptions-item>
<a-descriptions-item label="交互内存">{{ renderSize(machineInfo && machineInfo.osSwapTotal) }} </a-descriptions-item>
<a-descriptions-item label="硬盘">{{ renderSize(machineInfo && machineInfo.osFileStoreTotal) }} </a-descriptions-item>
<a-descriptions-item label="负载">{{ machineInfo && machineInfo.osLoadAverage }} </a-descriptions-item>
@ -63,8 +65,7 @@
<a-descriptions-item label="项目数">{{ machineInfo && machineInfo.jpomProjectCount }} </a-descriptions-item>
<a-descriptions-item label="脚本数">{{ machineInfo && machineInfo.jpomScriptCount }} </a-descriptions-item>
<a-descriptions-item label="网络延迟">{{ formatDuration(machineInfo && machineInfo.networkDelay) }} </a-descriptions-item>
<a-descriptions-item></a-descriptions-item>
<a-descriptions-item></a-descriptions-item>
<a-descriptions-item label="硬盘占用" :span="4">
<a-progress
:stroke-color="{