List of usage examples for org.springframework.boot.actuate.health Health.Builder up
public static Builder up()
From source file:it.tai.repository.MongoHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { CommandResult result = this.mongoTemplate.executeCommand("{ buildInfo: 1 }"); builder.up().withDetail("version", result.getString("version")); }
From source file:io.pivotal.strepsirrhini.chaosloris.CloudFoundryClientHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { requestGetInfo(this.cloudFoundryClient) .doOnSuccess(response -> builder.up().withDetail("apiVersion", response.getApiVersion())) .block(Duration.ofSeconds(10)); }
From source file:com.github.lburgazzoli.camel.boot.ApplicationHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { final long visits = controller.getVisits(); if (visits <= configuration.getMaxVisits()) { builder.up().withDetail("visitCount", visits).withDetail("visitMax", configuration.getMaxVisits()); } else {//from ww w . j a va 2 s .co m builder.down().withDetail("visitCount", visits).withDetail("visitMax", configuration.getMaxVisits()); } }
From source file:io.fabric8.spring.cloud.kubernetes.KubernetesHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { try {/* w w w . j a va 2 s .com*/ Pod current = utils.currentPod().get(); if (current != null) { builder.up().withDetail("inside", true) .withDetail("namespace", current.getMetadata().getNamespace()) .withDetail("podName", current.getMetadata().getName()) .withDetail("podIp", current.getStatus().getPodIP()) .withDetail("serviceAccount", current.getSpec().getServiceAccountName()) .withDetail("nodeName", current.getSpec().getNodeName()) .withDetail("hostIp", current.getStatus().getHostIP()); } else { builder.up().withDetail("inside", false); } } catch (Exception e) { builder.down(e); } }
From source file:com.netflix.spinnaker.fiat.config.ResourceProvidersHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { boolean isDown = false; for (HealthTrackable provider : providers) { builder.withDetail(provider.getClass().getSimpleName(), provider.getHealthTracker().getHealthView()); isDown = isDown || !provider.getHealthTracker().isProviderHealthy(); }// ww w .j a va2 s . c o m if (isDown) { if (previousHealthCheckIsUp.getAndSet(false)) { log.warn("Server is now UNHEALTHY"); } builder.down(); } else { if (!previousHealthCheckIsUp.getAndSet(true)) { log.info("Server is now HEALTHY. Hooray!"); } builder.up(); } }
From source file:com.netflix.spinnaker.echo.pipelinetriggers.health.MonitoredPollerHealth.java
private void polledRecently(Health.Builder builder) { Instant lastPollTimestamp = poller.getLastPollTimestamp(); if (lastPollTimestamp == null) { builder.unknown();/*from w ww . j a va2 s .c o m*/ } else { val timeSinceLastPoll = Duration.between(lastPollTimestamp, now()); builder.withDetail("last.polled", formatDurationWords(timeSinceLastPoll.toMillis(), true, true) + " ago"); builder.withDetail("last.polled.at", ISO_LOCAL_DATE_TIME.format(lastPollTimestamp.atZone(ZoneId.systemDefault()))); if (timeSinceLastPoll.compareTo(Duration.of(poller.getPollingIntervalSeconds() * 2, SECONDS)) <= 0) { builder.up(); } else { builder.down(); } } }
From source file:org.springframework.boot.actuate.health.DiskSpaceHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { File path = this.properties.getPath(); long diskFreeInBytes = path.getFreeSpace(); if (diskFreeInBytes >= this.properties.getThreshold()) { builder.up(); } else {/*from ww w . j a va2 s . co m*/ logger.warn( String.format("Free disk space below threshold. " + "Available: %d bytes (threshold: %d bytes)", diskFreeInBytes, this.properties.getThreshold())); builder.down(); } builder.withDetail("total", path.getTotalSpace()).withDetail("free", diskFreeInBytes) .withDetail("threshold", this.properties.getThreshold()); }
From source file:org.springframework.boot.actuate.jms.JmsHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { try (Connection connection = this.connectionFactory.createConnection()) { new MonitoredConnection(connection).start(); builder.up().withDetail("provider", connection.getMetaData().getJMSProviderName()); }/*from w ww . j a va 2s .c om*/ }
From source file:org.springframework.boot.actuate.system.DiskSpaceHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { long diskFreeInBytes = this.path.getUsableSpace(); if (diskFreeInBytes >= this.threshold) { builder.up(); } else {/*from w ww.j a va 2 s. c o m*/ logger.warn( String.format("Free disk space below threshold. " + "Available: %d bytes (threshold: %d bytes)", diskFreeInBytes, this.threshold)); builder.down(); } builder.withDetail("total", this.path.getTotalSpace()).withDetail("free", diskFreeInBytes) .withDetail("threshold", this.threshold); }
From source file:org.springframework.cloud.config.server.config.ConfigServerHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { builder.up(); List<Map<String, Object>> details = new ArrayList<>(); for (String name : this.repositories.keySet()) { Repository repository = this.repositories.get(name); String application = (repository.getName() == null) ? name : repository.getName(); String profiles = repository.getProfiles(); try {/*from w w w . j a v a2 s.co m*/ Environment environment = this.environmentRepository.findOne(application, profiles, repository.getLabel()); HashMap<String, Object> detail = new HashMap<>(); detail.put("name", environment.getName()); detail.put("label", environment.getLabel()); if (environment.getProfiles() != null && environment.getProfiles().length > 0) { detail.put("profiles", Arrays.asList(environment.getProfiles())); } if (!CollectionUtils.isEmpty(environment.getPropertySources())) { List<String> sources = new ArrayList<>(); for (PropertySource source : environment.getPropertySources()) { sources.add(source.getName()); } detail.put("sources", sources); } details.add(detail); } catch (Exception e) { logger.debug("Could not read repository: " + application, e); HashMap<String, String> map = new HashMap<>(); map.put("application", application); map.put("profiles", profiles); builder.withDetail("repository", map); builder.down(e); return; } } builder.withDetail("repositories", details); }