More work on processor metrics.
This commit is contained in:
parent
25e3640790
commit
3a4a4bdb8a
|
@ -52,7 +52,7 @@ public class ClientRouteBuilder extends RouteBuilder {
|
||||||
//.doTry()
|
//.doTry()
|
||||||
.process(new MetricEnrichProcessor(registry))
|
.process(new MetricEnrichProcessor(registry))
|
||||||
.choice().when(exchangeProperty("skip").isEqualTo(true))
|
.choice().when(exchangeProperty("skip").isEqualTo(true))
|
||||||
.log("Skipping empty: ${body}")
|
.log("Skipping empty measurement.")
|
||||||
.stop()
|
.stop()
|
||||||
.otherwise()
|
.otherwise()
|
||||||
.to("seda:metrics");
|
.to("seda:metrics");
|
||||||
|
|
|
@ -81,6 +81,7 @@ public class BaseDiskExtension implements MetricExtension {
|
||||||
fieldsMap.put("iotime", transferTime);
|
fieldsMap.put("iotime", transferTime);
|
||||||
fieldsMap.put("queue", queueLength);
|
fieldsMap.put("queue", queueLength);
|
||||||
|
|
||||||
|
log.debug(fieldsMap.toString());
|
||||||
return new MetricResult("disk", new Measurement(tagsMap, fieldsMap));
|
return new MetricResult("disk", new Measurement(tagsMap, fieldsMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class BaseMemoryExtension implements MetricExtension {
|
||||||
fieldsMap.put("paged", hardwareAbstractionLayer.getMemory().getPageSize());
|
fieldsMap.put("paged", hardwareAbstractionLayer.getMemory().getPageSize());
|
||||||
fieldsMap.put("virtual", hardwareAbstractionLayer.getMemory().getVirtualMemory().getVirtualInUse());
|
fieldsMap.put("virtual", hardwareAbstractionLayer.getMemory().getVirtualMemory().getVirtualInUse());
|
||||||
|
|
||||||
|
log.debug(fieldsMap.toString());
|
||||||
return new MetricResult("memory", new Measurement(tagsMap, fieldsMap));
|
return new MetricResult("memory", new Measurement(tagsMap, fieldsMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class BaseNetworkExtension implements MetricExtension {
|
||||||
fieldsMap.put("rxErrors", rxErrs);
|
fieldsMap.put("rxErrors", rxErrs);
|
||||||
fieldsMap.put("txErrors", txErrs);
|
fieldsMap.put("txErrors", txErrs);
|
||||||
|
|
||||||
|
log.debug(fieldsMap.toString());
|
||||||
return new MetricResult("network", new Measurement(tagsMap, fieldsMap));
|
return new MetricResult("network", new Measurement(tagsMap, fieldsMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class BaseProcessorExtension implements MetricExtension {
|
||||||
|
|
||||||
private SystemInfo systemInfo;
|
private SystemInfo systemInfo;
|
||||||
private HardwareAbstractionLayer hardwareAbstractionLayer;
|
private HardwareAbstractionLayer hardwareAbstractionLayer;
|
||||||
|
private long[] oldTicks;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSupported() {
|
public boolean isSupported() {
|
||||||
|
@ -63,48 +64,37 @@ public class BaseProcessorExtension implements MetricExtension {
|
||||||
Map<String, String> tagsMap = new HashMap<>();
|
Map<String, String> tagsMap = new HashMap<>();
|
||||||
Map<String, Object> fieldsMap = new HashMap<>();
|
Map<String, Object> fieldsMap = new HashMap<>();
|
||||||
|
|
||||||
long user = 0L;
|
long[] ticks = hardwareAbstractionLayer.getProcessor().getSystemCpuLoadTicks();
|
||||||
long system = 0L;
|
if(oldTicks == null || oldTicks.length != ticks.length) {
|
||||||
long steal = 0L;
|
oldTicks = ticks;
|
||||||
long irq = 0L;
|
return null;
|
||||||
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 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 busy = nice + user + system + steal + irq + softirq;
|
||||||
long nonBusy = idle + iowait;
|
long nonBusy = idle + iowait;
|
||||||
long total = busy + nonBusy;
|
long total = busy + nonBusy;
|
||||||
|
|
||||||
/*
|
fieldsMap.put("system", ((float) system / (float) total) * 100);
|
||||||
log.info("idle: " + idle);
|
fieldsMap.put("user", ((float) user / (float) total) * 100);
|
||||||
log.info("iowait: " + iowait);
|
fieldsMap.put("nice", ((float) nice / (float) total) * 100);
|
||||||
log.info("busy: " + busy);
|
fieldsMap.put("iowait", ((float) iowait / (float) total) * 100);
|
||||||
log.info("nonBusy: " + nonBusy);
|
fieldsMap.put("steal", ((float) steal / (float) total) * 100);
|
||||||
log.info("total: " + total);
|
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);
|
oldTicks = ticks;
|
||||||
fieldsMap.put("iowait", (float) iowait / (float) total);
|
log.debug(fieldsMap.toString());
|
||||||
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());
|
|
||||||
return new MetricResult("processor", new Measurement(tagsMap, fieldsMap));
|
return new MetricResult("processor", new Measurement(tagsMap, fieldsMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class LinuxNetworkExtension implements MetricExtension {
|
||||||
Map<String, String> tagsMap = sockStat.getTags();
|
Map<String, String> tagsMap = sockStat.getTags();
|
||||||
Map<String, Object> fieldsMap = sockStat.getFields();
|
Map<String, Object> fieldsMap = sockStat.getFields();
|
||||||
|
|
||||||
|
log.debug(fieldsMap.toString());
|
||||||
return new MetricResult("network_sockets", new Measurement(tagsMap, fieldsMap));
|
return new MetricResult("network_sockets", new Measurement(tagsMap, fieldsMap));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue