diff options
Diffstat (limited to 'spark-common/src')
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java b/spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java index 47e3fac..9c75dde 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java +++ b/spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java @@ -159,11 +159,16 @@ public enum CpuMonitor { BigDecimal systemCpuLoad = new BigDecimal(systemLoad()); BigDecimal processCpuLoad = new BigDecimal(processLoad()); - for (RollingAverage average : this.systemAverages) { - average.add(systemCpuLoad); + if (systemCpuLoad.signum() != -1) { // if value is not negative + for (RollingAverage average : this.systemAverages) { + average.add(systemCpuLoad); + } } - for (RollingAverage average : this.processAverages) { - average.add(processCpuLoad); + + if (processCpuLoad.signum() != -1) { // if value is not negative + for (RollingAverage average : this.processAverages) { + average.add(processCpuLoad); + } } } } |