Merge pull request #1856 from joshiste/systemLoad

* systemLoad:
  Add systemload.average to SystemPublicMetrics
pull/1860/head
Phillip Webb 10 years ago
commit 91fb4f22bd

@ -35,6 +35,7 @@ import org.springframework.util.StringUtils;
* @author Dave Syer * @author Dave Syer
* @author Christian Dupuis * @author Christian Dupuis
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Johannes Stelzer
* @since 1.2.0 * @since 1.2.0
*/ */
public class SystemPublicMetrics implements PublicMetrics, Ordered { public class SystemPublicMetrics implements PublicMetrics, Ordered {
@ -74,6 +75,8 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
.getUptime())); .getUptime()));
result.add(new Metric<Long>("instance.uptime", System.currentTimeMillis() result.add(new Metric<Long>("instance.uptime", System.currentTimeMillis()
- this.timestamp)); - this.timestamp));
result.add(new Metric<Double>("systemload.average", ManagementFactory
.getOperatingSystemMXBean().getSystemLoadAverage()));
} }
/** /**

@ -42,6 +42,7 @@ public class SystemPublicMetricsTests {
assertTrue(results.containsKey("mem.free")); assertTrue(results.containsKey("mem.free"));
assertTrue(results.containsKey("processors")); assertTrue(results.containsKey("processors"));
assertTrue(results.containsKey("uptime")); assertTrue(results.containsKey("uptime"));
assertTrue(results.containsKey("systemload.average"));
assertTrue(results.containsKey("heap.committed")); assertTrue(results.containsKey("heap.committed"));
assertTrue(results.containsKey("heap.init")); assertTrue(results.containsKey("heap.init"));

Loading…
Cancel
Save