in src/main/java/co/elastic/support/diagnostics/commands/CheckPlatformDetails.java [216:284]
public List<ProcessProfile> getNodeNetworkAndLogInfo(JsonNode nodesInfo) {
List<ProcessProfile> nodeNetworkInfo = new ArrayList<>();
try {
JsonNode nodes = nodesInfo.path("nodes");
Iterator<Map.Entry<String, JsonNode>> iterNode = nodes.fields();
while (iterNode.hasNext()) {
Map.Entry<String, JsonNode> n = iterNode.next();
String key = n.getKey();
JsonNode node = n.getValue();
ProcessProfile diagNode = new ProcessProfile();
diagNode.id = key;
diagNode.name = node.path("name").asText();
diagNode.pid = node.path("process").path("id").asText();
diagNode.jvmPid = node.path("jvm").path("pid").asText();
if (diagNode.pid.equals("1") || diagNode.jvmPid.equals("1")) {
diagNode.isDocker = true;
}
JsonNode settings = node.path("settings");
JsonNode path = settings.path("path");
JsonNode logs = path.path("logs");
diagNode.logDir = node.path("settings").path("path").path("logs").asText();
diagNode.networkHost = node.path("settings").path("network").path("host").asText();
diagNode.host = (node.path("host").asText());
diagNode.ip = (node.path("ip").asText());
String nodeOs = node.path("os").path("name").asText().toLowerCase();
diagNode.os = SystemUtils.parseOperatingSystemName(nodeOs);
diagNode.javaPlatform = new JavaPlatform(diagNode.os);
String httpPublishAddr = node.path("http").path("publish_address").asText();
diagNode.httpPublishAddr = httpPublishAddr.substring(0, httpPublishAddr.indexOf(":"));
diagNode.httpPort = Integer.parseInt(httpPublishAddr.substring(httpPublishAddr.indexOf(":") + 1));
// This won't work for version 1 - it will always be empty so it will
// never go after logs.
JsonNode bnds = node.path("http").path("bound_address");
if (bnds instanceof ArrayNode) {
diagNode.isHttp = true;
ArrayNode boundAddresses = (ArrayNode) bnds;
for (JsonNode bnd : boundAddresses) {
String addr = bnd.asText();
// See if the bound address is a loopback. If so, we don't need it
boolean notLoopBack = true;
for (String loopback : Constants.localAddressList) {
if (addr.contains(loopback)) {
notLoopBack = false;
}
}
if (notLoopBack) {
addr = addr.substring(0, addr.indexOf(":"));
diagNode.boundAddresses.add(addr);
}
}
}
nodeNetworkInfo.add(diagNode);
}
} catch (Exception e) {
logger.error("Error extracting node network addresses from nodes output", e);
}
return nodeNetworkInfo;
}