@Test public void testGetMetrics() throws Exception { CpuGaugeSet set = new CpuGaugeSet(); Map<String, Metric> metrics = set.getMetrics(); assertThat((Integer) ((Gauge) metrics.get(CpuGaugeSet.PROCESSORS)).getValue()).isGreaterThan(0); assertThat(((Gauge) metrics.get(CpuGaugeSet.CPU_PROCESS_LOAD)).getValue()).isNotNull(); assertThat(((Gauge) metrics.get(CpuGaugeSet.CPU_PROCESS_TIME)).getValue()).isNotNull(); assertThat(((Gauge) metrics.get(CpuGaugeSet.SYSTEM_LOAD_AVERAGE)).getValue()).isNotNull(); assertThat(((Gauge) metrics.get(CpuGaugeSet.CPU_SYSTEM_LOAD)).getValue()).isNotNull(); }
public Map<String, Metric> getMetrics() { return ImmutableMap.<String, Metric>of( PROCESSORS, new Gauge<Integer>() { public Integer getValue() { return bean.getAvailableProcessors(); } }, SYSTEM_LOAD_AVERAGE, new Gauge<Double>() { public Double getValue() { return bean.getSystemLoadAverage(); } }, CPU_SYSTEM_LOAD, new Gauge<Double>() { public Double getValue() { return getSystemCpuLoad(); } }, CPU_PROCESS_LOAD, new Gauge<Double>() { public Double getValue() { return getCpuProcessLoad(); } }, CPU_PROCESS_TIME, new Gauge<Long>() { public Long getValue() { return getCpuTime(); } } ); }
CpuGaugeSet implements MetricSet { public Map<String, Metric> getMetrics() { return ImmutableMap.<String, Metric>of( PROCESSORS, new Gauge<Integer>() { public Integer getValue() { return bean.getAvailableProcessors(); } }, SYSTEM_LOAD_AVERAGE, new Gauge<Double>() { public Double getValue() { return bean.getSystemLoadAverage(); } }, CPU_SYSTEM_LOAD, new Gauge<Double>() { public Double getValue() { return getSystemCpuLoad(); } }, CPU_PROCESS_LOAD, new Gauge<Double>() { public Double getValue() { return getCpuProcessLoad(); } }, CPU_PROCESS_TIME, new Gauge<Long>() { public Long getValue() { return getCpuTime(); } } ); } }
CpuGaugeSet implements MetricSet { public Map<String, Metric> getMetrics() { return ImmutableMap.<String, Metric>of( PROCESSORS, new Gauge<Integer>() { public Integer getValue() { return bean.getAvailableProcessors(); } }, SYSTEM_LOAD_AVERAGE, new Gauge<Double>() { public Double getValue() { return bean.getSystemLoadAverage(); } }, CPU_SYSTEM_LOAD, new Gauge<Double>() { public Double getValue() { return getSystemCpuLoad(); } }, CPU_PROCESS_LOAD, new Gauge<Double>() { public Double getValue() { return getCpuProcessLoad(); } }, CPU_PROCESS_TIME, new Gauge<Long>() { public Long getValue() { return getCpuTime(); } } ); }  }
CpuGaugeSet implements MetricSet { public Map<String, Metric> getMetrics() { return ImmutableMap.<String, Metric>of( PROCESSORS, new Gauge<Integer>() { public Integer getValue() { return bean.getAvailableProcessors(); } }, SYSTEM_LOAD_AVERAGE, new Gauge<Double>() { public Double getValue() { return bean.getSystemLoadAverage(); } }, CPU_SYSTEM_LOAD, new Gauge<Double>() { public Double getValue() { return getSystemCpuLoad(); } }, CPU_PROCESS_LOAD, new Gauge<Double>() { public Double getValue() { return getCpuProcessLoad(); } }, CPU_PROCESS_TIME, new Gauge<Long>() { public Long getValue() { return getCpuTime(); } } ); }  Map<String, Metric> getMetrics(); }
CpuGaugeSet implements MetricSet { public Map<String, Metric> getMetrics() { return ImmutableMap.<String, Metric>of( PROCESSORS, new Gauge<Integer>() { public Integer getValue() { return bean.getAvailableProcessors(); } }, SYSTEM_LOAD_AVERAGE, new Gauge<Double>() { public Double getValue() { return bean.getSystemLoadAverage(); } }, CPU_SYSTEM_LOAD, new Gauge<Double>() { public Double getValue() { return getSystemCpuLoad(); } }, CPU_PROCESS_LOAD, new Gauge<Double>() { public Double getValue() { return getCpuProcessLoad(); } }, CPU_PROCESS_TIME, new Gauge<Long>() { public Long getValue() { return getCpuTime(); } } ); }  Map<String, Metric> getMetrics(); static final String PROCESSORS; static final String SYSTEM_LOAD_AVERAGE; static final String CPU_SYSTEM_LOAD; static final String CPU_PROCESS_LOAD; static final String CPU_PROCESS_TIME; }