|
|
@@ -1,9 +1,6 @@
|
|
|
-package cn.reghao.autodop.common.machine;
|
|
|
+package cn.reghao.autodop.common.machine.cpu;
|
|
|
|
|
|
import cn.reghao.autodop.common.machine.contant.ProcFile;
|
|
|
-import cn.reghao.autodop.common.machine.pojo.CPUInfo;
|
|
|
-import cn.reghao.autodop.common.machine.pojo.cpu.CpuStats;
|
|
|
-import cn.reghao.autodop.common.machine.pojo.cpu.CpuStat;
|
|
|
import cn.reghao.autodop.common.machine.utils.AbstractPercentageCalculator;
|
|
|
import cn.reghao.autodop.common.machine.utils.CpuPercentageCalculator;
|
|
|
import cn.reghao.autodop.common.utils.text.TextFile;
|
|
|
@@ -29,29 +26,12 @@ public class CPU {
|
|
|
}
|
|
|
Map<String, String> map = list.get(0);
|
|
|
CPUInfo cpuInfo = new CPUInfo();
|
|
|
- cpuInfo.setModelName(map.get("model name"));
|
|
|
- cpuInfo.setCpus(list.size());
|
|
|
- cpuInfo.setCpuCores(Integer.parseInt(map.get("cpu cores")));
|
|
|
- cpuInfo.setBogomips(Double.parseDouble(map.get("bogomips")));
|
|
|
return cpuInfo;
|
|
|
}
|
|
|
|
|
|
private List<Map<String, String>> parseCpuInfo() {
|
|
|
String info = textFile.readFile(ProcFile.CPU_INFO);
|
|
|
List<Map<String, String>> list = new ArrayList<>();
|
|
|
- Map<String, String> map = new LinkedHashMap<>();
|
|
|
- for (String line : info.split(System.lineSeparator())) {
|
|
|
- if (!line.isEmpty()) {
|
|
|
- String[] strs = line.replace("\t", "").split(":");
|
|
|
- if (!strs[0].startsWith("power management")) {
|
|
|
- map.put(strs[0], strs[1].replace(" ", ""));
|
|
|
- }
|
|
|
- } else {
|
|
|
- list.add(map);
|
|
|
- map = new LinkedHashMap<>();
|
|
|
- }
|
|
|
- }
|
|
|
- list.add(map);
|
|
|
return list;
|
|
|
}
|
|
|
|