mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 19:48:07 +01:00
Report the maximum number of file descriptors allowed by the OS.
This commit is contained in:
committed by
Jon Chambers
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.GarbageCollectionCountGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.GarbageCollectionTimeGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.MaxFileDescriptorGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.MetricsApplicationEventListener;
|
||||
import org.whispersystems.textsecuregcm.metrics.NetworkReceivedGauge;
|
||||
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(GarbageCollectionCountGauge.class, "gc_count"), new GarbageCollectionCountGauge());
|
||||
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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user