summary refs log tree commit diff
path: root/synapse/metrics/__init__.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2016-10-19 14:50:57 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2016-10-19 15:05:21 +0100
commitdef63649df49528113f5e84d23576956baaf851e (patch)
tree70f51646e1228da9a847e07e40b887e77466b277 /synapse/metrics/__init__.py
parentAdd standard process_open_fds metric (diff)
downloadsynapse-def63649df49528113f5e84d23576956baaf851e.tar.xz
Add standard process_max_fds metric
Diffstat (limited to 'synapse/metrics/__init__.py')
-rw-r--r--synapse/metrics/__init__.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index dfbb634af9..75ba248c56 100644
--- a/synapse/metrics/__init__.py
+++ b/synapse/metrics/__init__.py
@@ -205,6 +205,19 @@ process_metrics.register_callback(
     "open_fds", lambda: sum(fd_counts.values())
 )
 
+def _get_max_fds():
+    with open("/proc/self/limits") as limits:
+        for line in limits:
+            if not line.startswith("Max open files "):
+                continue
+            # Line is  Max open files  $SOFT  $HARD
+            return int(line.split()[3])
+    return None
+
+process_metrics.register_callback(
+    "max_fds", lambda: _get_max_fds()
+)
+
 reactor_metrics = get_metrics_for("reactor")
 tick_time = reactor_metrics.register_distribution("tick_time")
 pending_calls_metric = reactor_metrics.register_distribution("pending_calls")