use of com.codahale.metrics.CachedGauge in project alluxio by Alluxio.
the class OperationSystemGaugeSet method getMetrics.
@Override
public Map<String, Metric> getMetrics() {
final Map<String, Metric> gauges = new HashMap<>();
try {
mOsmxb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
mUnixb = (UnixOperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
} catch (Throwable e) {
return gauges;
}
gauges.put("os.freePhysicalMemory", new CachedGauge(10, TimeUnit.MINUTES) {
@Override
protected Long loadValue() {
return mOsmxb.getFreePhysicalMemorySize();
}
});
gauges.put("os.totalPhysicalMemory", new CachedGauge<Long>(10, TimeUnit.MINUTES) {
@Override
protected Long loadValue() {
return mOsmxb.getTotalPhysicalMemorySize();
}
});
gauges.put("os.cpuLoad", new CachedGauge<Double>(10, TimeUnit.MINUTES) {
@Override
protected Double loadValue() {
return mOsmxb.getSystemCpuLoad();
}
});
gauges.put("os.maxFileCount", new CachedGauge<Long>(10, TimeUnit.MINUTES) {
@Override
protected Long loadValue() {
return mUnixb.getMaxFileDescriptorCount();
}
});
gauges.put("os.openFileCount", new CachedGauge<Long>(10, TimeUnit.MINUTES) {
@Override
protected Long loadValue() {
return mUnixb.getOpenFileDescriptorCount();
}
});
return gauges;
}
Aggregations