public class NodeHealth {
private boolean master;
+ private String address;
private long jvmHeapMax;
private long jvmHeapUsed;
private long fsAvailable;
this.master = master;
}
+ public String getAddress() {
+ return address;
+ }
+
+ void setAddress(String address) {
+ this.address = address;
+ }
+
void setJvmHeapMax(long bytes) {
this.jvmHeapMax = bytes;
}
// Master/slave
setMaster(nodesStats.getNode().isMasterNode());
+ // Host IP and port
+ setAddress(nodesStats.getNode().getAddress().toString());
+
// JVM Heap Usage
setJvmHeapMax(nodesStats.getJvm().getMem().getHeapMax().bytes());
setJvmHeapUsed(nodesStats.getJvm().getMem().getHeapUsed().bytes());
- // OS Memory Usage ?
- // nodesStats.getOs().getMem().freePercent();
-
// Disk Usage
setFsTotal(nodesStats.getFs().getTotal().getTotal().bytes());
setFsAvailable(nodesStats.getFs().getTotal().getAvailable().bytes());
import org.junit.ClassRule;
import org.junit.Test;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.rule.RuleTesting;
+import org.sonar.server.rule.db.RuleDao;
import org.sonar.server.tester.ServerTester;
import java.util.Date;
@Test
public void get_search_health(){
+ DbSession dbSession = tester.get(DbClient.class).openSession(false);
+ tester.get(RuleDao.class).insert(dbSession, RuleTesting.newDto(RuleKey.of("javascript", "S001")));
+ dbSession.commit();
+
SearchHealth health = tester.get(SearchHealth.class);
Date now = new Date();
NodeHealth nodeHealth = health.getNodesHealth().values().iterator().next();
assertThat(nodeHealth.isMaster()).isTrue();
+ System.out.println(nodeHealth.getAddress());
+ assertThat(nodeHealth.getAddress()).contains(":");
assertThat(nodeHealth.getJvmHeapUsedPercent()).contains("%");
assertThat(nodeHealth.getFsUsedPercent()).contains("%");
assertThat(nodeHealth.getJvmThreads()).isGreaterThanOrEqualTo(0L);
node_info=[]
add_property(node_info, 'Node Name') { name }
add_property(node_info, 'Node Type') { node_health.isMaster() ? 'Master' : 'Slave' }
+ add_property(node_info, 'Node Address') { node_health.getAddress() }
add_property(node_info, 'JVM Heap Usage') { node_health.getJvmHeapUsedPercent() }
add_property(node_info, 'JVM Threads') { node_health.getJvmThreads() }
add_property(node_info, 'JVM Uptime') { Internal.i18n.ageFromNow(node_health.getJvmUpSince()) }