Files
tr-agent-client/src/main/java/com/tongran/agent/client/utils/AgentDataUtil.java
T

27 lines
829 B
Java
Raw Normal View History

2025-09-10 15:36:49 +08:00
package com.tongran.agent.client.utils;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class AgentDataUtil {
public static Map<String, Long> parseMemInfo() throws IOException {
Map<String, Long> memInfo = new HashMap<>();
try (BufferedReader br = new BufferedReader(new FileReader("/proc/meminfo"))) {
String line;
while ((line = br.readLine()) != null) {
String[] parts = line.split("\\s+");
if (parts.length >= 2) {
String key = parts[0].replace(":", "");
long value = Long.parseLong(parts[1]);
memInfo.put(key, value);
}
}
}
return memInfo;
}
}