Report the maximum number of file descriptors allowed by the OS.
This commit is contained in:
parent
95428ab8b0
commit
e9b0829860
|
@ -89,6 +89,7 @@ import org.whispersystems.textsecuregcm.metrics.FileDescriptorGauge;
|
||||||
import org.whispersystems.textsecuregcm.metrics.FreeMemoryGauge;
|
import org.whispersystems.textsecuregcm.metrics.FreeMemoryGauge;
|
||||||
import org.whispersystems.textsecuregcm.metrics.GarbageCollectionCountGauge;
|
import org.whispersystems.textsecuregcm.metrics.GarbageCollectionCountGauge;
|
||||||
import org.whispersystems.textsecuregcm.metrics.GarbageCollectionTimeGauge;
|
import org.whispersystems.textsecuregcm.metrics.GarbageCollectionTimeGauge;
|
||||||
|
import org.whispersystems.textsecuregcm.metrics.MaxFileDescriptorGauge;
|
||||||
import org.whispersystems.textsecuregcm.metrics.MetricsApplicationEventListener;
|
import org.whispersystems.textsecuregcm.metrics.MetricsApplicationEventListener;
|
||||||
import org.whispersystems.textsecuregcm.metrics.NetworkReceivedGauge;
|
import org.whispersystems.textsecuregcm.metrics.NetworkReceivedGauge;
|
||||||
import org.whispersystems.textsecuregcm.metrics.NetworkSentGauge;
|
import org.whispersystems.textsecuregcm.metrics.NetworkSentGauge;
|
||||||
|
@ -451,6 +452,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||||
environment.metrics().register(name(FileDescriptorGauge.class, "fd_count"), new FileDescriptorGauge());
|
environment.metrics().register(name(FileDescriptorGauge.class, "fd_count"), new FileDescriptorGauge());
|
||||||
environment.metrics().register(name(GarbageCollectionCountGauge.class, "gc_count"), new GarbageCollectionCountGauge());
|
environment.metrics().register(name(GarbageCollectionCountGauge.class, "gc_count"), new GarbageCollectionCountGauge());
|
||||||
environment.metrics().register(name(GarbageCollectionTimeGauge.class, "gc_time"), new GarbageCollectionTimeGauge());
|
environment.metrics().register(name(GarbageCollectionTimeGauge.class, "gc_time"), new GarbageCollectionTimeGauge());
|
||||||
|
environment.metrics().register(name(MaxFileDescriptorGauge.class, "max_fd_count"), new MaxFileDescriptorGauge());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerExceptionMappers(Environment environment, WebSocketEnvironment<Account> webSocketEnvironment, WebSocketEnvironment<Account> provisioningEnvironment) {
|
private void registerExceptionMappers(Environment environment, WebSocketEnvironment<Account> webSocketEnvironment, WebSocketEnvironment<Account> provisioningEnvironment) {
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue