// Path: src/main/java/cn/jiongjionger/neverlag/hardware/UnixCPUInfo.java
// public class UnixCPUInfo {
// 
// 	public String getProcessorData() {
// 		List<String> streamProcessorInfo = HardwareInfoUtils.readFile("/proc/cpuinfo");
// 		final StringBuilder buffer = new StringBuilder();
// 		for (String line : streamProcessorInfo) {
// 			buffer.append(line).append("\r\n");
// 		}
// 		return buffer.toString();
// 	}
// 
// 	public Map<String, String> parseInfo() {
// 		HashMap<String, String> processorDataMap = new HashMap<>();
// 		String[] dataStringLines = getProcessorData().split("\\r?\\n");
// 		for (final String dataLine : dataStringLines) {
// 			String[] dataStringInfo = dataLine.split(":");
// 			processorDataMap.put(dataStringInfo[0].trim(),
// 					(dataStringInfo.length == 2) ? dataStringInfo[1].trim() : "");
// 		}
// 		return processorDataMap;
// 	}
// }
// 
// Path: src/main/java/cn/jiongjionger/neverlag/hardware/UnixMemoryInfo.java
// public class UnixMemoryInfo {
// 
// 	private String getMemoryData() {
// 		List<String> streamMemoryInfo = HardwareInfoUtils.readFile("/proc/meminfo");
// 		final StringBuilder buffer = new StringBuilder();
// 		for (String line : streamMemoryInfo) {
// 			buffer.append(line).append("\r\n");
// 		}
// 		return buffer.toString();
// 	}
// 
// 	public HashMap<String, String> parseInfo() {
// 		HashMap<String, String> memoryDataMap = new HashMap<>();
// 		String[] dataStringLines = getMemoryData().split("\\r?\\n");
// 		for (final String dataLine : dataStringLines) {
// 			String[] dataStringInfo = dataLine.split(":");
// 			memoryDataMap.put(dataStringInfo[0].trim(), (dataStringInfo.length == 2) ? dataStringInfo[1].trim() : "");
// 		}
// 		return memoryDataMap;
// 	}
// }
// 
// Path: src/main/java/cn/jiongjionger/neverlag/hardware/WindowsCPUInfo.java
// public class WindowsCPUInfo {
// 
// 	public Map<String, String> parseInfo() {
// 		Map<String, String> processorDataMap = WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_PROCESSOR);
// 		String lineInfos = processorDataMap.get("Description");
// 		String[] infos = lineInfos.split("\\s+");
// 		processorDataMap.put("cpu family", infos[2]);
// 		processorDataMap.put("model", infos[4]);
// 		processorDataMap.put("stepping", infos[6]);
// 		processorDataMap.put("model name", processorDataMap.get("Name"));
// 		processorDataMap.put("cpu MHz", processorDataMap.get("MaxClockSpeed"));
// 		processorDataMap.put("vendor_id", processorDataMap.get("Manufacturer"));
// 		processorDataMap.put("cpu cores", processorDataMap.get("NumberOfCores"));
// 		return processorDataMap;
// 	}
// }
// 
// Path: src/main/java/cn/jiongjionger/neverlag/hardware/WindowsMemoryInfo.java
// public class WindowsMemoryInfo {
// 
// 	public Map<String, String> parseInfo() {
// 		Map<String, String> memoryDataMap = WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_PERFFORMATTEDDATA_PERFOS_MEMORY);
// 		memoryDataMap.putAll(WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_PHYSICALMEMORY));
// 		memoryDataMap.put("MemAvailable", memoryDataMap.get("AvailableKBytes"));
// 		memoryDataMap.put("MemFree", WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_OPERATINGSYSTEM).get("FreePhysicalMemory"));
// 		memoryDataMap.put("MemTotal", WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_OPERATINGSYSTEM).get("TotalPhysicalMemory"));
// 		return memoryDataMap;
// 	}
// }


import cn.jiongjionger.neverlag.hardware.UnixCPUInfo;
import cn.jiongjionger.neverlag.hardware.UnixMemoryInfo;
import cn.jiongjionger.neverlag.hardware.WindowsCPUInfo;
import cn.jiongjionger.neverlag.hardware.WindowsMemoryInfo;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.util.HashMap;
import java.util.Map;
package cn.jiongjionger.neverlag.utils;



public final class HardwareInfo {

	private static final String OS = System.getProperty("os.name").toLowerCase();
	private static final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
	private static final OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
	private static Map<String, String> cpuInfoMap = new HashMap<>();

	// 获取CPU信息（类似Intel(R) Xeon(R) CPU E5-2679V4 @ 3.2GHz 20 cores B0 stepping）
	public static String getCPUInfo() {
		try {
			synchronized (cpuInfoMap) {
				if (isWindows()) {
					if (cpuInfoMap.isEmpty()) {
						WindowsCPUInfo cpuInfo = new WindowsCPUInfo();
						cpuInfoMap = cpuInfo.parseInfo();
					}
				} else if (isUnix()) {
					if (cpuInfoMap.isEmpty()) {
// Path: src/main/java/cn/jiongjionger/neverlag/hardware/UnixCPUInfo.java
// public class UnixCPUInfo {
// 
// 	public String getProcessorData() {
// 		List<String> streamProcessorInfo = HardwareInfoUtils.readFile("/proc/cpuinfo");
// 		final StringBuilder buffer = new StringBuilder();
// 		for (String line : streamProcessorInfo) {
// 			buffer.append(line).append("\r\n");
// 		}
// 		return buffer.toString();
// 	}
// 
// 	public Map<String, String> parseInfo() {
// 		HashMap<String, String> processorDataMap = new HashMap<>();
// 		String[] dataStringLines = getProcessorData().split("\\r?\\n");
// 		for (final String dataLine : dataStringLines) {
// 			String[] dataStringInfo = dataLine.split(":");
// 			processorDataMap.put(dataStringInfo[0].trim(),
// 					(dataStringInfo.length == 2) ? dataStringInfo[1].trim() : "");
// 		}
// 		return processorDataMap;
// 	}
// }
// 
// Path: src/main/java/cn/jiongjionger/neverlag/hardware/UnixMemoryInfo.java
// public class UnixMemoryInfo {
// 
// 	private String getMemoryData() {
// 		List<String> streamMemoryInfo = HardwareInfoUtils.readFile("/proc/meminfo");
// 		final StringBuilder buffer = new StringBuilder();
// 		for (String line : streamMemoryInfo) {
// 			buffer.append(line).append("\r\n");
// 		}
// 		return buffer.toString();
// 	}
// 
// 	public HashMap<String, String> parseInfo() {
// 		HashMap<String, String> memoryDataMap = new HashMap<>();
// 		String[] dataStringLines = getMemoryData().split("\\r?\\n");
// 		for (final String dataLine : dataStringLines) {
// 			String[] dataStringInfo = dataLine.split(":");
// 			memoryDataMap.put(dataStringInfo[0].trim(), (dataStringInfo.length == 2) ? dataStringInfo[1].trim() : "");
// 		}
// 		return memoryDataMap;
// 	}
// }
// 
// Path: src/main/java/cn/jiongjionger/neverlag/hardware/WindowsCPUInfo.java
// public class WindowsCPUInfo {
// 
// 	public Map<String, String> parseInfo() {
// 		Map<String, String> processorDataMap = WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_PROCESSOR);
// 		String lineInfos = processorDataMap.get("Description");
// 		String[] infos = lineInfos.split("\\s+");
// 		processorDataMap.put("cpu family", infos[2]);
// 		processorDataMap.put("model", infos[4]);
// 		processorDataMap.put("stepping", infos[6]);
// 		processorDataMap.put("model name", processorDataMap.get("Name"));
// 		processorDataMap.put("cpu MHz", processorDataMap.get("MaxClockSpeed"));
// 		processorDataMap.put("vendor_id", processorDataMap.get("Manufacturer"));
// 		processorDataMap.put("cpu cores", processorDataMap.get("NumberOfCores"));
// 		return processorDataMap;
// 	}
// }
// 
// Path: src/main/java/cn/jiongjionger/neverlag/hardware/WindowsMemoryInfo.java
// public class WindowsMemoryInfo {
// 
// 	public Map<String, String> parseInfo() {
// 		Map<String, String> memoryDataMap = WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_PERFFORMATTEDDATA_PERFOS_MEMORY);
// 		memoryDataMap.putAll(WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_PHYSICALMEMORY));
// 		memoryDataMap.put("MemAvailable", memoryDataMap.get("AvailableKBytes"));
// 		memoryDataMap.put("MemFree", WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_OPERATINGSYSTEM).get("FreePhysicalMemory"));
// 		memoryDataMap.put("MemTotal", WMI4Java.get().VBSEngine().getWMIObject(WMIClass.WIN32_OPERATINGSYSTEM).get("TotalPhysicalMemory"));
// 		return memoryDataMap;
// 	}
// }


// Path: src/main/java/cn/jiongjionger/neverlag/utils/HardwareInfo.java
import cn.jiongjionger.neverlag.hardware.UnixCPUInfo;
import cn.jiongjionger.neverlag.hardware.UnixMemoryInfo;
import cn.jiongjionger.neverlag.hardware.WindowsCPUInfo;
import cn.jiongjionger.neverlag.hardware.WindowsMemoryInfo;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.util.HashMap;
import java.util.Map;

package cn.jiongjionger.neverlag.utils;



public final class HardwareInfo {

	private static final String OS = System.getProperty("os.name").toLowerCase();
	private static final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
	private static final OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
	private static Map<String, String> cpuInfoMap = new HashMap<>();

	// 获取CPU信息（类似Intel(R) Xeon(R) CPU E5-2679V4 @ 3.2GHz 20 cores B0 stepping）
	public static String getCPUInfo() {
		try {
			synchronized (cpuInfoMap) {
				if (isWindows()) {
					if (cpuInfoMap.isEmpty()) {
						WindowsCPUInfo cpuInfo = new WindowsCPUInfo();
						cpuInfoMap = cpuInfo.parseInfo();
					}
				} else if (isUnix()) {
					if (cpuInfoMap.isEmpty()) {
						UnixCPUInfo cpuInfo = new UnixCPUInfo();