]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9802 add cpu usage of ES in cluster mode
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 25 Sep 2017 20:11:19 +0000 (22:11 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 26 Sep 2017 21:49:38 +0000 (23:49 +0200)
server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsStateSection.java
server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/EsStateSectionTest.java

index 40d8803dbf9c169bc0dcdb533ad9171f2e1dad7a..5700c23bdc31aa12389a774c0341471aa288e1bb 100644 (file)
@@ -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());
index af248d636405c76948983879b8c6cd7573fab5fc..cdcffa418bfd5acac92dda6c69cffc50493008f2 100644 (file)
@@ -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();
   }