Search in sources :

Example 1 with FabricStatus

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;
}
Also used : PrintStream(java.io.PrintStream) FabricStatus(io.fabric8.api.FabricStatus)

Example 2 with FabricStatus

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;
}
Also used : HealthStatus(io.fabric8.api.jmx.HealthStatus) ArrayList(java.util.ArrayList) ProfileStatus(io.fabric8.api.ProfileStatus) FabricStatus(io.fabric8.api.FabricStatus)

Example 3 with FabricStatus

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)));
    }
}
Also used : ProfileStatus(io.fabric8.api.ProfileStatus)

Aggregations

FabricStatus (io.fabric8.api.FabricStatus)2 ProfileStatus (io.fabric8.api.ProfileStatus)2 HealthStatus (io.fabric8.api.jmx.HealthStatus)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1