jsp.status.jsp Maven / Gradle / Ivy
The newest version!
<%@ page language="java" import="java.util.*,java.util.Map.Entry,com.netflix.discovery.shared.Pair,
com.netflix.discovery.shared.*,com.netflix.eureka.util.*,com.netflix.appinfo.InstanceInfo.*,
com.netflix.appinfo.DataCenterInfo.*,com.netflix.appinfo.AmazonInfo.MetaDataKey,com.netflix.eureka.resources.*,
com.netflix.eureka.*,com.netflix.appinfo.*,com.netflix.eureka.util.StatusUtil" pageEncoding="UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
Eureka
Instances currently registered with Eureka
Application AMIs Availability Zones Status
Application AMIs Availability Zones Status
<%
EurekaServerContext serverContext = (EurekaServerContext) pageContext.getServletContext()
.getAttribute(EurekaServerContext.class.getName());
for(Application app : serverContext.getRegistry().getSortedApplications()) {
out.print("" + app.getName() + " ");
Map amiCounts = new HashMap();
Map>> instancesByStatus =
new HashMap>>();
Map zoneCounts = new HashMap();
for(InstanceInfo info : app.getInstances()){
String id = info.getId();
String url = info.getStatusPageUrl();
InstanceStatus status = info.getStatus();
String ami = "n/a";
String zone = "";
if(info.getDataCenterInfo().getName() == Name.Amazon){
AmazonInfo dcInfo = (AmazonInfo)info.getDataCenterInfo();
ami = dcInfo.get(MetaDataKey.amiId);
zone = dcInfo.get(MetaDataKey.availabilityZone);
}
Integer count = amiCounts.get(ami);
if(count != null){
amiCounts.put(ami, Integer.valueOf(count.intValue()+1));
}else {
amiCounts.put(ami, Integer.valueOf(1));
}
count = zoneCounts.get(zone);
if(count != null){
zoneCounts.put(zone, Integer.valueOf(count.intValue()+1));
}else {
zoneCounts.put(zone, Integer.valueOf(1));
}
List> list = instancesByStatus.get(status);
if(list == null){
list = new ArrayList>();
instancesByStatus.put(status, list);
}
list.add(new Pair(id, url));
}
StringBuilder buf = new StringBuilder();
for (Iterator> iter =
amiCounts.entrySet().iterator(); iter.hasNext();) {
Entry entry = iter.next();
buf.append("").append(entry.getKey()).append(" (").append(entry.getValue()).append("), ");
}
out.println("" + buf.toString() + " ");
buf = new StringBuilder();
for (Iterator> iter =
zoneCounts.entrySet().iterator(); iter.hasNext();) {
Entry entry = iter.next();
buf.append("").append(entry.getKey()).append(" (").append(entry.getValue()).append("), ");
}
out.println("" + buf.toString() + " ");
buf = new StringBuilder();
for (Iterator>>> iter =
instancesByStatus.entrySet().iterator(); iter.hasNext();) {
Entry>> entry = iter.next();
List> value = entry.getValue();
InstanceStatus status = entry.getKey();
if(status != InstanceStatus.UP){
buf.append("");
}
buf.append("").append(status.name()).append(" (").append(value.size()).append(") - ");
if(status != InstanceStatus.UP){
buf.append("");
}
for(Pair p : value) {
String id = p.first();
String url = p.second();
if(url != null && url.startsWith("http")){
buf.append("");
}else {
url = null;
}
buf.append(id);
if(url != null){
buf.append("");
}
buf.append(", ");
}
}
out.println("" + buf.toString() + " ");
}
%>
General Info
Name Value
<%
StatusInfo statusInfo = (new StatusUtil(serverContext)).getStatusInfo();
Map genMap = statusInfo.getGeneralStats();
for (Map.Entry entry : genMap.entrySet()) {
out.print("");
out.print("" + entry.getKey() + " " + entry.getValue() + " ");
out.print(" ");
}
Map appMap = statusInfo.getApplicationStats();
for (Map.Entry entry : appMap.entrySet()) {
out.print("");
out.print("" + entry.getKey() + " " + entry.getValue() + " ");
out.print(" ");
}
%>
Instance Info
Name Value
<%
InstanceInfo instanceInfo = statusInfo.getInstanceInfo();
Map instanceMap = new HashMap();
instanceMap.put("ipAddr", instanceInfo.getIPAddr());
instanceMap.put("status", instanceInfo.getStatus().toString());
if(instanceInfo.getDataCenterInfo().getName() == DataCenterInfo.Name.Amazon) {
AmazonInfo info = (AmazonInfo) instanceInfo.getDataCenterInfo();
instanceMap.put("availability-zone", info.get(AmazonInfo.MetaDataKey.availabilityZone));
instanceMap.put("public-ipv4", info.get(AmazonInfo.MetaDataKey.publicIpv4));
instanceMap.put("instance-id", info.get(AmazonInfo.MetaDataKey.instanceId));
instanceMap.put("public-hostname", info.get(AmazonInfo.MetaDataKey.publicHostname));
instanceMap.put("ami-id", info.get(AmazonInfo.MetaDataKey.amiId));
instanceMap.put("instance-type", info.get(AmazonInfo.MetaDataKey.instanceType));
}
for (Map.Entry entry : instanceMap.entrySet()) {
out.print("");
out.print("" + entry.getKey() + " " + entry.getValue() + " ");
out.print(" ");
}
%>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy