use of io.fabric8.api.jmx.HealthStatus in project fabric8 by jboss-fuse.
the class HealthCheck method healthList.
@Override
public List<HealthStatus> healthList() {
List<HealthStatus> answer = new ArrayList<HealthStatus>();
FabricStatus status = fabricService.getFabricStatus();
Collection<ProfileStatus> statuses = status.getProfileStatusMap().values();
for (ProfileStatus profile : statuses) {
String id = profile.getProfile();
int instances = profile.getCount();
Integer minimum = profile.getMinimumInstances();
Integer maximum = profile.getMaximumInstances();
double healthPercent = profile.getHealth(instances);
String level = "INFO";
String message = "Profile " + id + " has health " + percentInstance.format(healthPercent);
if (minimum != null) {
if (instances <= 0) {
level = "ERROR";
message = "Profile " + id + " has no instances running! Should have at least " + minimum;
} else if (instances < minimum) {
level = "WARNING";
message = "Profile " + id + " needs more instances running. Should have at least " + minimum + " but currently has only " + instances;
}
}
if (maximum != null && level.equals("INFO") && instances > maximum) {
level = "WARNING";
message = "Profile " + id + " has too many instances running. Should have at most " + maximum + " but currently has only " + instances;
}
answer.add(new HealthStatus("io.fabric8.profileHealth", id, level, message, instances, minimum, maximum, healthPercent));
}
String worries = "";
for (HealthStatus hs : answer) {
if ("WARNING".equals(hs.getLevel()) || "ERROR".equals(hs.getLevel())) {
worries += hs + " , ";
}
}
if ("".equals(worries)) {
this.currentStatus = "Good";
} else {
this.currentStatus = "Getting Worried {" + worries + " }";
}
return answer;
}
Aggregations