1.启动增加检查监控策略机制;
2.cpu上报数据单位优化
This commit is contained in:
@@ -631,5 +631,49 @@ public class AgentUtil {
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统 HZ(每秒 tick 数)
|
||||
* 典型值:100, 250, 300, 1000
|
||||
*/
|
||||
public static int getSystemHz() {
|
||||
if (GlobalConfig.systemHz != null) {
|
||||
return GlobalConfig.systemHz;
|
||||
}
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec(
|
||||
"grep CONFIG_HZ /boot/config-$(uname -r)"
|
||||
);
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream())
|
||||
);
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.contains("CONFIG_HZ=")) {
|
||||
String[] parts = line.split("=");
|
||||
int hz = Integer.parseInt(parts[1].trim());
|
||||
GlobalConfig.systemHz = hz;
|
||||
return hz;
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
System.err.println("无法读取系统 HZ,使用默认值 1000");
|
||||
}
|
||||
|
||||
// 默认值(大多数现代 Linux 发行版使用 1000 Hz)
|
||||
GlobalConfig.systemHz = 1000;
|
||||
return GlobalConfig.systemHz;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ticks 转换为秒
|
||||
*/
|
||||
public static double ticksToSeconds(long ticks) {
|
||||
int hz = getSystemHz();
|
||||
return (double) ticks / hz;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user