mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-02 04:08:31 +08:00
Filter the NaN of system_cpu_usage/process_cpu_usage (#16289)
This commit is contained in:
parent
8f6df8d840
commit
255ec35c3b
@ -33,6 +33,9 @@ public class DefaultMetricsProvider implements MetricsProvider {
|
|||||||
|
|
||||||
private long lastRefreshTime = 0;
|
private long lastRefreshTime = 0;
|
||||||
|
|
||||||
|
private double lastSystemCpuUsage = 0.0d;
|
||||||
|
private double lastProcessCpuUsage = 0.0d;
|
||||||
|
|
||||||
private static final long SYSTEM_METRICS_REFRESH_INTERVAL = 1_000L;
|
private static final long SYSTEM_METRICS_REFRESH_INTERVAL = 1_000L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +45,17 @@ public class DefaultMetricsProvider implements MetricsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double systemCpuUsage = meterRegistry.get("system.cpu.usage").gauge().value();
|
double systemCpuUsage = meterRegistry.get("system.cpu.usage").gauge().value();
|
||||||
|
if (Double.compare(systemCpuUsage, Double.NaN) == 0) {
|
||||||
|
systemCpuUsage = lastSystemCpuUsage;
|
||||||
|
} else {
|
||||||
|
lastSystemCpuUsage = systemCpuUsage;
|
||||||
|
}
|
||||||
double processCpuUsage = meterRegistry.get("process.cpu.usage").gauge().value();
|
double processCpuUsage = meterRegistry.get("process.cpu.usage").gauge().value();
|
||||||
|
if (Double.compare(processCpuUsage, Double.NaN) == 0) {
|
||||||
|
processCpuUsage = lastProcessCpuUsage;
|
||||||
|
} else {
|
||||||
|
lastProcessCpuUsage = processCpuUsage;
|
||||||
|
}
|
||||||
|
|
||||||
double jvmMemoryUsed = meterRegistry.get("jvm.memory.used").meter().measure().iterator().next().getValue();
|
double jvmMemoryUsed = meterRegistry.get("jvm.memory.used").meter().measure().iterator().next().getValue();
|
||||||
double jvmMemoryMax = meterRegistry.get("jvm.memory.max").meter().measure().iterator().next().getValue();
|
double jvmMemoryMax = meterRegistry.get("jvm.memory.max").meter().measure().iterator().next().getValue();
|
||||||
|
Loading…
Reference in New Issue
Block a user