diff --git a/client/src/main/java/sysmon/client/ClientRouteBuilder.java b/client/src/main/java/sysmon/client/ClientRouteBuilder.java index bf9db77..e17108a 100644 --- a/client/src/main/java/sysmon/client/ClientRouteBuilder.java +++ b/client/src/main/java/sysmon/client/ClientRouteBuilder.java @@ -52,7 +52,7 @@ public class ClientRouteBuilder extends RouteBuilder { //.doTry() .process(new MetricEnrichProcessor(registry)) .choice().when(exchangeProperty("skip").isEqualTo(true)) - .log("Skipping empty: ${body}") + .log("Skipping empty measurement.") .stop() .otherwise() .to("seda:metrics"); diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java index 477b8e5..2f8c433 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java @@ -81,6 +81,7 @@ public class BaseDiskExtension implements MetricExtension { fieldsMap.put("iotime", transferTime); fieldsMap.put("queue", queueLength); + log.debug(fieldsMap.toString()); return new MetricResult("disk", new Measurement(tagsMap, fieldsMap)); } diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseMemoryExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseMemoryExtension.java index 4af172a..b73ad48 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseMemoryExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseMemoryExtension.java @@ -65,6 +65,7 @@ public class BaseMemoryExtension implements MetricExtension { fieldsMap.put("paged", hardwareAbstractionLayer.getMemory().getPageSize()); fieldsMap.put("virtual", hardwareAbstractionLayer.getMemory().getVirtualMemory().getVirtualInUse()); + log.debug(fieldsMap.toString()); return new MetricResult("memory", new Measurement(tagsMap, fieldsMap)); } diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetworkExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetworkExtension.java index 74e67a4..8b5a7c0 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetworkExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetworkExtension.java @@ -83,6 +83,7 @@ public class BaseNetworkExtension implements MetricExtension { fieldsMap.put("rxErrors", rxErrs); fieldsMap.put("txErrors", txErrs); + log.debug(fieldsMap.toString()); return new MetricResult("network", new Measurement(tagsMap, fieldsMap)); } diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseProcessorExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseProcessorExtension.java index ce3c800..9b39018 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseProcessorExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseProcessorExtension.java @@ -26,6 +26,7 @@ public class BaseProcessorExtension implements MetricExtension { private SystemInfo systemInfo; private HardwareAbstractionLayer hardwareAbstractionLayer; + private long[] oldTicks; @Override public boolean isSupported() { @@ -63,48 +64,37 @@ public class BaseProcessorExtension implements MetricExtension { Map tagsMap = new HashMap<>(); Map fieldsMap = new HashMap<>(); - long user = 0L; - long system = 0L; - long steal = 0L; - long irq = 0L; - long softirq = 0L; - long nice = 0L; - long idle = 0L; - long iowait = 0L; - - long[][] ticks = hardwareAbstractionLayer.getProcessor().getProcessorCpuLoadTicks(); - int cores = ticks.length; - //log.warn("Cores: " + cores); - for (long[] tick : ticks) { - nice += tick[CentralProcessor.TickType.NICE.getIndex()]; - user += tick[CentralProcessor.TickType.USER.getIndex()]; - system += tick[CentralProcessor.TickType.SYSTEM.getIndex()]; - steal += tick[CentralProcessor.TickType.STEAL.getIndex()]; - irq += tick[CentralProcessor.TickType.IRQ.getIndex()]; - softirq += tick[CentralProcessor.TickType.SOFTIRQ.getIndex()]; - idle += tick[CentralProcessor.TickType.IDLE.getIndex()]; - iowait += tick[CentralProcessor.TickType.IOWAIT.getIndex()]; + long[] ticks = hardwareAbstractionLayer.getProcessor().getSystemCpuLoadTicks(); + if(oldTicks == null || oldTicks.length != ticks.length) { + oldTicks = ticks; + return null; } + long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - oldTicks[CentralProcessor.TickType.NICE.getIndex()]; + long user = ticks[CentralProcessor.TickType.USER.getIndex()] - oldTicks[CentralProcessor.TickType.USER.getIndex()]; + long system = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - oldTicks[CentralProcessor.TickType.SYSTEM.getIndex()]; + long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - oldTicks[CentralProcessor.TickType.STEAL.getIndex()]; + long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - oldTicks[CentralProcessor.TickType.IRQ.getIndex()]; + long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - oldTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()]; + long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - oldTicks[CentralProcessor.TickType.IDLE.getIndex()]; + long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - oldTicks[CentralProcessor.TickType.IOWAIT.getIndex()]; + long busy = nice + user + system + steal + irq + softirq; long nonBusy = idle + iowait; long total = busy + nonBusy; - /* - log.info("idle: " + idle); - log.info("iowait: " + iowait); - log.info("busy: " + busy); - log.info("nonBusy: " + nonBusy); - log.info("total: " + total); - */ + fieldsMap.put("system", ((float) system / (float) total) * 100); + fieldsMap.put("user", ((float) user / (float) total) * 100); + fieldsMap.put("nice", ((float) nice / (float) total) * 100); + fieldsMap.put("iowait", ((float) iowait / (float) total) * 100); + fieldsMap.put("steal", ((float) steal / (float) total) * 100); + fieldsMap.put("irq", ((float) irq / (float) total) * 100); + fieldsMap.put("softirq", ((float) softirq / (float) total) * 100); + fieldsMap.put("idle", ((float) idle / (float) total) * 100); + fieldsMap.put("busy", ((float) busy / (float) total) * 100); - fieldsMap.put("user", (float) user / (float) total); - fieldsMap.put("iowait", (float) iowait / (float) total); - fieldsMap.put("idle", (float) nonBusy / (float) total); - fieldsMap.put("busy", (float) busy / (float) total); - fieldsMap.put("system", (float) system / (float) total); - - //log.info(fieldsMap.toString()); + oldTicks = ticks; + log.debug(fieldsMap.toString()); return new MetricResult("processor", new Measurement(tagsMap, fieldsMap)); } diff --git a/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetworkExtension.java b/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetworkExtension.java index 666051c..bb842b1 100644 --- a/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetworkExtension.java +++ b/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetworkExtension.java @@ -50,6 +50,7 @@ public class LinuxNetworkExtension implements MetricExtension { Map tagsMap = sockStat.getTags(); Map fieldsMap = sockStat.getFields(); + log.debug(fieldsMap.toString()); return new MetricResult("network_sockets", new Measurement(tagsMap, fieldsMap)); }