use of org.opensearch.monitor.jvm.JvmStats.BufferPool in project fess by codelibs.
the class SystemMonitorTarget method appendJvmStats.
private void appendJvmStats(final StringBuilder buf) {
buf.append("\"jvm\":{");
final JvmStats jvmStats = JvmStats.jvmStats();
final Mem mem = jvmStats.getMem();
buf.append("\"memory\":{");
buf.append("\"heap\":{");
append(buf, "used", () -> mem.getHeapUsed().getBytes()).append(',');
append(buf, "committed", () -> mem.getHeapCommitted().getBytes()).append(',');
append(buf, "max", () -> mem.getHeapMax().getBytes()).append(',');
append(buf, "percent", () -> mem.getHeapUsedPercent());
buf.append("},");
buf.append("\"non_heap\":{");
append(buf, "used", () -> mem.getNonHeapUsed().getBytes()).append(',');
append(buf, "committed", () -> mem.getNonHeapCommitted().getBytes());
buf.append('}');
buf.append("},");
final List<BufferPool> bufferPools = jvmStats.getBufferPools();
buf.append("\"pools\":{");
buf.append(bufferPools.stream().map(p -> {
final StringBuilder b = new StringBuilder();
b.append('"').append(StringEscapeUtils.escapeJson(p.getName())).append("\":{");
append(b, "count", () -> p.getCount()).append(',');
append(b, "used", () -> p.getUsed().getBytes()).append(',');
append(b, "capacity", () -> p.getTotalCapacity().getBytes()).append('}');
return b.toString();
}).collect(Collectors.joining(",")));
buf.append("},");
final GarbageCollectors gc = jvmStats.getGc();
buf.append("\"gc\":{");
buf.append(Arrays.stream(gc.getCollectors()).map(c -> {
final StringBuilder b = new StringBuilder();
b.append('"').append(StringEscapeUtils.escapeJson(c.getName())).append("\":{");
append(b, "count", () -> c.getCollectionCount()).append(',');
append(b, "time", () -> c.getCollectionTime().getMillis()).append('}');
return b.toString();
}).collect(Collectors.joining(",")));
buf.append("},");
final Threads threads = jvmStats.getThreads();
buf.append("\"threads\":{");
append(buf, "count", () -> threads.getCount()).append(',');
append(buf, "peak", () -> threads.getPeakCount());
buf.append("},");
final Classes classes = jvmStats.getClasses();
buf.append("\"classes\":{");
append(buf, "loaded", () -> classes.getLoadedClassCount()).append(',');
append(buf, "total_loaded", () -> classes.getTotalLoadedClassCount()).append(',');
append(buf, "unloaded", () -> classes.getUnloadedClassCount());
buf.append("},");
append(buf, "uptime", () -> jvmStats.getUptime().getMillis());
buf.append("},");
}
Aggregations