|
@@ -68,7 +68,7 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void expired() {
|
|
public void expired() {
|
|
- StringBuilder buf = new StringBuilder(1000);
|
|
|
|
|
|
+ final StringBuilder buf = new StringBuilder(1000);
|
|
|
|
|
|
buf.append("[SYSTEM MONITOR] ");
|
|
buf.append("[SYSTEM MONITOR] ");
|
|
buf.append('{');
|
|
buf.append('{');
|
|
@@ -84,10 +84,10 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|
logger.info(buf.toString());
|
|
logger.info(buf.toString());
|
|
}
|
|
}
|
|
|
|
|
|
- private void appendJvmStats(StringBuilder buf) {
|
|
|
|
|
|
+ private void appendJvmStats(final StringBuilder buf) {
|
|
buf.append("\"jvm\":{");
|
|
buf.append("\"jvm\":{");
|
|
final JvmStats jvmStats = JvmStats.jvmStats();
|
|
final JvmStats jvmStats = JvmStats.jvmStats();
|
|
- Mem mem = jvmStats.getMem();
|
|
|
|
|
|
+ final Mem mem = jvmStats.getMem();
|
|
buf.append("\"memory\":{");
|
|
buf.append("\"memory\":{");
|
|
buf.append("\"heap\":{");
|
|
buf.append("\"heap\":{");
|
|
append(buf, "used", () -> mem.getHeapUsed().bytesAsInt()).append(',');
|
|
append(buf, "used", () -> mem.getHeapUsed().bytesAsInt()).append(',');
|
|
@@ -100,10 +100,10 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|
append(buf, "committed", () -> mem.getNonHeapCommitted().bytesAsInt());
|
|
append(buf, "committed", () -> mem.getNonHeapCommitted().bytesAsInt());
|
|
buf.append('}');
|
|
buf.append('}');
|
|
buf.append("},");
|
|
buf.append("},");
|
|
- List<BufferPool> bufferPools = jvmStats.getBufferPools();
|
|
|
|
|
|
+ final List<BufferPool> bufferPools = jvmStats.getBufferPools();
|
|
buf.append("\"pools\":{");
|
|
buf.append("\"pools\":{");
|
|
buf.append(bufferPools.stream().map(p -> {
|
|
buf.append(bufferPools.stream().map(p -> {
|
|
- StringBuilder b = new StringBuilder();
|
|
|
|
|
|
+ final StringBuilder b = new StringBuilder();
|
|
b.append('"').append(StringEscapeUtils.escapeJson(p.getName())).append("\":{");
|
|
b.append('"').append(StringEscapeUtils.escapeJson(p.getName())).append("\":{");
|
|
append(b, "count", () -> p.getCount()).append(',');
|
|
append(b, "count", () -> p.getCount()).append(',');
|
|
append(b, "used", () -> p.getUsed().bytesAsInt()).append(',');
|
|
append(b, "used", () -> p.getUsed().bytesAsInt()).append(',');
|
|
@@ -111,22 +111,22 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|
return b.toString();
|
|
return b.toString();
|
|
}).collect(Collectors.joining(",")));
|
|
}).collect(Collectors.joining(",")));
|
|
buf.append("},");
|
|
buf.append("},");
|
|
- GarbageCollectors gc = jvmStats.getGc();
|
|
|
|
|
|
+ final GarbageCollectors gc = jvmStats.getGc();
|
|
buf.append("\"gc\":{");
|
|
buf.append("\"gc\":{");
|
|
buf.append(Arrays.stream(gc.getCollectors()).map(c -> {
|
|
buf.append(Arrays.stream(gc.getCollectors()).map(c -> {
|
|
- StringBuilder b = new StringBuilder();
|
|
|
|
|
|
+ final StringBuilder b = new StringBuilder();
|
|
b.append('"').append(StringEscapeUtils.escapeJson(c.getName())).append("\":{");
|
|
b.append('"').append(StringEscapeUtils.escapeJson(c.getName())).append("\":{");
|
|
append(b, "count", () -> c.getCollectionCount()).append(',');
|
|
append(b, "count", () -> c.getCollectionCount()).append(',');
|
|
append(b, "time", () -> c.getCollectionTime().getMillis()).append('}');
|
|
append(b, "time", () -> c.getCollectionTime().getMillis()).append('}');
|
|
return b.toString();
|
|
return b.toString();
|
|
}).collect(Collectors.joining(",")));
|
|
}).collect(Collectors.joining(",")));
|
|
buf.append("},");
|
|
buf.append("},");
|
|
- Threads threads = jvmStats.getThreads();
|
|
|
|
|
|
+ final Threads threads = jvmStats.getThreads();
|
|
buf.append("\"threads\":{");
|
|
buf.append("\"threads\":{");
|
|
append(buf, "count", () -> threads.getCount()).append(',');
|
|
append(buf, "count", () -> threads.getCount()).append(',');
|
|
append(buf, "peak", () -> threads.getPeakCount());
|
|
append(buf, "peak", () -> threads.getPeakCount());
|
|
buf.append("},");
|
|
buf.append("},");
|
|
- Classes classes = jvmStats.getClasses();
|
|
|
|
|
|
+ final Classes classes = jvmStats.getClasses();
|
|
buf.append("\"classes\":{");
|
|
buf.append("\"classes\":{");
|
|
append(buf, "loaded", () -> classes.getLoadedClassCount()).append(',');
|
|
append(buf, "loaded", () -> classes.getLoadedClassCount()).append(',');
|
|
append(buf, "total_loaded", () -> classes.getTotalLoadedClassCount()).append(',');
|
|
append(buf, "total_loaded", () -> classes.getTotalLoadedClassCount()).append(',');
|
|
@@ -136,7 +136,7 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|
buf.append("},");
|
|
buf.append("},");
|
|
}
|
|
}
|
|
|
|
|
|
- private void appendProcessStats(StringBuilder buf) {
|
|
|
|
|
|
+ private void appendProcessStats(final StringBuilder buf) {
|
|
buf.append("\"process\":{");
|
|
buf.append("\"process\":{");
|
|
final ProcessProbe processProbe = ProcessProbe.getInstance();
|
|
final ProcessProbe processProbe = ProcessProbe.getInstance();
|
|
buf.append("\"file_descriptor\":{");
|
|
buf.append("\"file_descriptor\":{");
|
|
@@ -153,7 +153,7 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|
buf.append("},");
|
|
buf.append("},");
|
|
}
|
|
}
|
|
|
|
|
|
- private void appendOsStats(StringBuilder buf) {
|
|
|
|
|
|
+ private void appendOsStats(final StringBuilder buf) {
|
|
buf.append("\"os\":{");
|
|
buf.append("\"os\":{");
|
|
final OsProbe osProbe = OsProbe.getInstance();
|
|
final OsProbe osProbe = OsProbe.getInstance();
|
|
buf.append("\"memory\":{");
|
|
buf.append("\"memory\":{");
|
|
@@ -168,26 +168,26 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|
buf.append("},");
|
|
buf.append("},");
|
|
buf.append("\"cpu\":{");
|
|
buf.append("\"cpu\":{");
|
|
append(buf, "percent", () -> osProbe.getSystemCpuPercent());
|
|
append(buf, "percent", () -> osProbe.getSystemCpuPercent());
|
|
- OsStats osStats = osProbe.osStats();
|
|
|
|
|
|
+ final OsStats osStats = osProbe.osStats();
|
|
buf.append("},");
|
|
buf.append("},");
|
|
append(buf, "load_averages", () -> osStats.getCpu().getLoadAverage());
|
|
append(buf, "load_averages", () -> osStats.getCpu().getLoadAverage());
|
|
buf.append("},");
|
|
buf.append("},");
|
|
}
|
|
}
|
|
|
|
|
|
- private void appendElasticsearchStats(StringBuilder buf) {
|
|
|
|
|
|
+ private void appendElasticsearchStats(final StringBuilder buf) {
|
|
String stats = null;
|
|
String stats = null;
|
|
try {
|
|
try {
|
|
- FessEsClient esClient = ComponentUtil.getFessEsClient();
|
|
|
|
- NodesStatsResponse response =
|
|
|
|
|
|
+ final FessEsClient esClient = ComponentUtil.getFessEsClient();
|
|
|
|
+ final NodesStatsResponse response =
|
|
esClient.admin().cluster().prepareNodesStats().ingest(false).setBreaker(false).setDiscovery(false).setFs(true)
|
|
esClient.admin().cluster().prepareNodesStats().ingest(false).setBreaker(false).setDiscovery(false).setFs(true)
|
|
.setHttp(false).setIndices(true).setJvm(true).setOs(true).setProcess(true).setScript(false).setThreadPool(true)
|
|
.setHttp(false).setIndices(true).setJvm(true).setOs(true).setProcess(true).setScript(false).setThreadPool(true)
|
|
.setTransport(true).execute().actionGet(10000L);
|
|
.setTransport(true).execute().actionGet(10000L);
|
|
- XContentBuilder builder = XContentFactory.jsonBuilder();
|
|
|
|
|
|
+ final XContentBuilder builder = XContentFactory.jsonBuilder();
|
|
builder.startObject();
|
|
builder.startObject();
|
|
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
|
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
|
builder.endObject();
|
|
builder.endObject();
|
|
stats = builder.string();
|
|
stats = builder.string();
|
|
- } catch (Exception e) {
|
|
|
|
|
|
+ } catch (final Exception e) {
|
|
logger.debug("Failed to access Elasticsearch stats.", e);
|
|
logger.debug("Failed to access Elasticsearch stats.", e);
|
|
}
|
|
}
|
|
buf.append("\"elasticsearch\":").append(stats).append(',');
|
|
buf.append("\"elasticsearch\":").append(stats).append(',');
|