Skip to content

Commit

Permalink
Remove the use of CPU health indicator. (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoymajumdar authored and tgianos committed Jan 12, 2017
1 parent 99a9d78 commit bc694bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotNull;
import java.lang.management.ManagementFactory;
Expand All @@ -37,7 +36,6 @@
* @author amajumdar
* @since 3.0.0
*/
@Component
@Slf4j
public class GenieCpuHealthIndicator implements HealthIndicator {
private static final String CPU_LOAD = "cpuLoad";
Expand Down Expand Up @@ -86,7 +84,7 @@ public Health health() {
final long cpuCount = summaryCpuMetric.getCount();
final long cpuTotal = summaryCpuMetric.getTotalAmount();
final double currentCpuLoadPercent =
cpuCount == 0 ? operatingSystemMXBean.getProcessCpuLoad() : (cpuTotal / (double) cpuCount);
cpuCount == 0 ? operatingSystemMXBean.getSystemCpuLoad() : (cpuTotal / (double) cpuCount);
if (currentCpuLoadPercent > maxCpuLoadPercent) {
cpuLoadConsecutiveOccurrences++;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class GenieCpuHealthIndicatorSpec extends Specification{
def checkHealth(){
when:
def okOperatingSystemMXBean = Mock(OperatingSystemMXBean)
okOperatingSystemMXBean.getSystemCpuLoad() >> 0.75 >> 0.78
okOperatingSystemMXBean.getSystemCpuLoad() >> 0.75
def indicator = new GenieCpuHealthIndicator( 80, 1, okOperatingSystemMXBean,
new BasicDistributionSummary(MonitorConfig.builder('s').build()), new DefaultManagedTaskScheduler())
then:
indicator.health().getStatus() == Status.UP
when:
def outOperatingSystemMXBean = Mock(OperatingSystemMXBean)
outOperatingSystemMXBean.getSystemCpuLoad() >> 0.85 >> 0.88
outOperatingSystemMXBean.getSystemCpuLoad() >> 0.85
indicator = new GenieCpuHealthIndicator( 80, 1, outOperatingSystemMXBean,
new BasicDistributionSummary(MonitorConfig.builder('s').build()), new DefaultManagedTaskScheduler())
then:
Expand Down

0 comments on commit bc694bf

Please sign in to comment.