use of io.fabric8.api.FabricStatus in project fabric8 by jboss-fuse.
the class StatusAction method doExecute.
@Override
protected Object doExecute() throws Exception {
PrintStream out = System.out;
FabricStatus status = getFabricService().getFabricStatus();
printStatus(out, status);
return null;
}
use of io.fabric8.api.FabricStatus 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;
}
use of io.fabric8.api.FabricStatus in project fabric8 by jboss-fuse.
the class StatusAction method printStatus.
protected void printStatus(PrintStream out, FabricStatus status) {
out.println(String.format("%-40s %-14s %s", "[profile]", "[instances]", "[health]"));
Collection<ProfileStatus> statuses = status.getProfileStatusMap().values();
for (ProfileStatus profile : statuses) {
String id = profile.getProfile();
int instances = profile.getCount();
double health = profile.getHealth(instances);
out.println(String.format("%-40s %-14s %s", id, instances, percentText(health)));
}
}
Aggregations