初始化
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user