}
}
exchange.setResponseCode(200);
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, "text/html; charset=ISO-8859-1");
final Sender resp = exchange.getResponseSender();
final StringBuilder buf = new StringBuilder();
buf.append("<html><head>\n<title>Mod_cluster Status</title>\n</head><body>\n");
buf.append("<h1>" + MOD_CLUSTER_EXPOSED_VERSION + "</h1>");
final String uri = exchange.getRequestPath();
final String nonce = getNonce();
if (refreshTime <= 0) {
buf.append("<a href=\"").append(uri).append("?").append(nonce).append("&refresh=").append(refreshTime).append("\">Auto Refresh</a>");
}
buf.append(" <a href=\"").append(uri).append("?").append(nonce).append("&Cmd=DUMP&Range=ALL").append("\">show DUMP output</a>");
buf.append(" <a href=\"").append(uri).append("?").append(nonce).append("&Cmd=INFO&Range=ALL").append("\">show INFO output</a>");
buf.append("\n");
// Show load balancing groups
final Map<String, List<Node>> nodes = new LinkedHashMap<>();
for (final Node node : container.getNodes()) {
final String domain = node.getNodeConfig().getDomain() != null ? node.getNodeConfig().getDomain() : "";
List<Node> list = nodes.get(domain);
if (list == null) {
list = new ArrayList<>();
nodes.put(domain, list);
}
list.add(node);
}
for (Map.Entry<String, List<Node>> entry : nodes.entrySet()) {
final String groupName = entry.getKey();
if (reduceDisplay) {
buf.append("<br/><br/>LBGroup " + groupName + ": ");
} else {
buf.append("<h1> LBGroup " + groupName + ": ");
}
if (allowCmd) {
domainCommandString(buf, uri, MCMPAction.ENABLE, groupName);
domainCommandString(buf, uri, MCMPAction.DISABLE, groupName);
}
for (final Node node : entry.getValue()) {
final NodeConfig nodeConfig = node.getNodeConfig();
if (reduceDisplay) {
buf.append("<br/><br/>Node " + nodeConfig.getJvmRoute());
printProxyStat(buf, node, reduceDisplay);
} else {
buf.append("<h1> Node " + nodeConfig.getJvmRoute() + " (" + nodeConfig.getConnectionURI() + "): </h1>\n");
}
if (allowCmd) {
nodeCommandString(buf, uri, MCMPAction.ENABLE, nodeConfig.getJvmRoute());
nodeCommandString(buf, uri, MCMPAction.DISABLE, nodeConfig.getJvmRoute());
}
if (!reduceDisplay) {
buf.append("<br/>\n");
buf.append("Balancer: " + nodeConfig.getBalancer() + ",LBGroup: " + nodeConfig.getDomain());
String flushpackets = "off";
if (nodeConfig.isFlushPackets()) {
flushpackets = "Auto";
}
buf.append(",Flushpackets: " + flushpackets + ",Flushwait: " + nodeConfig.getFlushwait() + ",Ping: " + nodeConfig.getPing() + " ,Smax: " + nodeConfig.getPing() + ",Ttl: " + nodeConfig.getTtl());
printProxyStat(buf, node, reduceDisplay);
} else {
buf.append("<br/>\n");
}
// the sessionid list is mostly for demos.
if (displaySessionIds) {
// buf.append(",Num sessions: " + container.getJVMRouteSessionCount(nodeConfig.getJvmRoute()));
}
buf.append("\n");
// Process the virtual-host of the node
printInfoHost(buf, uri, reduceDisplay, allowCmd, node);
}
}
// Display the all the actives sessions
if (displaySessionIds) {
printInfoSessions(buf, Collections.<SessionId>emptyList());
}
buf.append("</body></html>\n");
resp.send(buf.toString());
}