Report the maximum number of file descriptors allowed by the OS.

This commit is contained in:
Jon Chambers
2020-10-09 19:39:12 -04:00
committed by Jon Chambers
parent 95428ab8b0
commit e9b0829860
2 changed files with 25 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package org.whispersystems.textsecuregcm.metrics;
import com.codahale.metrics.Gauge;
import com.sun.management.UnixOperatingSystemMXBean;
import java.lang.management.ManagementFactory;
/**
* A gauge that reports the maximum number of file descriptors allowed by the operating system.
*/
public class MaxFileDescriptorGauge implements Gauge<Long> {
private final UnixOperatingSystemMXBean unixOperatingSystemMXBean;
public MaxFileDescriptorGauge() {
this.unixOperatingSystemMXBean = (UnixOperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
}
@Override
public Long getValue() {
return unixOperatingSystemMXBean.getMaxFileDescriptorCount();
}
}