org.kiwiproject.dropwizard.util.metrics.ServerLoadGauge Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropwizard-service-utilities Show documentation
Show all versions of dropwizard-service-utilities Show documentation
Set of utilities to aid in setting up Dropwizard services
package org.kiwiproject.dropwizard.util.metrics;
import static org.kiwiproject.base.KiwiStrings.format;
import com.codahale.metrics.Gauge;
/**
* A {@link Gauge} that reports the current server load average, as reported by the {@code uptime} command.
*
* If the load average was not obtainable for some reason, returns {@link ServerLoadFetcher#NO_VALUE}
*/
public class ServerLoadGauge implements Gauge{
public static final String NAME = format("{}.{}.load-average",
ServerLoadGauge.class.getPackage().getName(),
ServerLoadGauge.class.getSimpleName().replace("Gauge", ""));
private final ServerLoadFetcher loadAverage = new ServerLoadFetcher();
@Override
public String getValue() {
return loadAverage.get().orElse(ServerLoadFetcher.NO_VALUE);
}
}