From e9bd8978f291768fa1283bcff6a4d6179b87f53b Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 25 Sep 2017 22:11:19 +0200 Subject: [PATCH] SONAR-9802 add cpu usage of ES in cluster mode --- .../org/sonar/server/platform/monitoring/EsStateSection.java | 1 + .../sonar/server/platform/monitoring/EsStateSectionTest.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsStateSection.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsStateSection.java index 40d8803dbf9..5700c23bdc3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsStateSection.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsStateSection.java @@ -74,6 +74,7 @@ public class EsStateSection implements SystemInfoSection { } public static void toProtobuf(NodeStats stats, ProtobufSystemInfo.Section.Builder protobuf) { + setAttribute(protobuf, "CPU Usage (%)", stats.getProcess().getCpu().getPercent()); setAttribute(protobuf, "Disk Available", byteCountToDisplaySize(stats.getFs().getTotal().getAvailable().getBytes())); setAttribute(protobuf, "Store Size", byteCountToDisplaySize(stats.getIndices().getStore().getSizeInBytes())); setAttribute(protobuf, "Open File Descriptors", stats.getProcess().getOpenFileDescriptors()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/EsStateSectionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/EsStateSectionTest.java index af248d63640..cdcffa418bf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/EsStateSectionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/EsStateSectionTest.java @@ -55,6 +55,8 @@ public class EsStateSectionTest { @Test public void node_attributes() { ProtobufSystemInfo.Section section = underTest.toProtobuf(); + assertThat(attribute(section, "CPU Usage (%)")).isNotNull(); + assertThat(attribute(section, "Disk Available")).isNotNull(); assertThat(attribute(section, "Store Size")).isNotNull(); } -- 2.39.5