内存利用率数据优化

This commit is contained in:
qiminbao
2025-10-31 14:16:45 +08:00
parent 4669573373
commit b2d6f2f655
@@ -5,6 +5,7 @@ import com.tongran.agent.client.core.vo.SystemVO;
import com.tongran.agent.client.service.SystemService; import com.tongran.agent.client.service.SystemService;
import com.tongran.agent.client.utils.AgentDataUtil; import com.tongran.agent.client.utils.AgentDataUtil;
import com.tongran.agent.client.utils.AgentUtil; import com.tongran.agent.client.utils.AgentUtil;
import com.tongran.agent.client.utils.AssertLog;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import oshi.SystemInfo; import oshi.SystemInfo;
import oshi.hardware.CentralProcessor; import oshi.hardware.CentralProcessor;
@@ -165,6 +166,7 @@ public class SystemServiceImpl implements SystemService {
// long buffers = memInfo.getOrDefault("Buffers", 0L); // long buffers = memInfo.getOrDefault("Buffers", 0L);
// double actualUsage = (double)(total - available - cached - buffers) / total * 100; // double actualUsage = (double)(total - available - cached - buffers) / total * 100;
double actualUsage = (double)(total - available) / total * 100; double actualUsage = (double)(total - available) / total * 100;
AssertLog.info("memoryUtilizationCollect,内存使用率:{}",actualUsage);
System.out.printf("实际内存使用率: %.2f%%\n", actualUsage); System.out.printf("实际内存使用率: %.2f%%\n", actualUsage);
return actualUsage; return actualUsage;
} catch (IOException e) { } catch (IOException e) {