diff options
author | Erik Johnston <erik@matrix.org> | 2015-09-10 10:32:10 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-09-10 10:32:10 +0100 |
commit | 4ae73d16a90ac27edaeb5ae69a91d2a97e9cfa5c (patch) | |
tree | 629eca13251ae1f83e3baa1fbf56f82b0a9a574d /synapse/metrics/__init__.py | |
parent | Merge pull request #273 from matrix-org/erikj/key_fetch_fix (diff) | |
parent | Check that /proc/self/fd exists before listing it (diff) | |
download | synapse-4ae73d16a90ac27edaeb5ae69a91d2a97e9cfa5c.tar.xz |
Merge pull request #270 from matrix-org/markjh/fix_metrics
Fix the size reported by maxrss.
Diffstat (limited to 'synapse/metrics/__init__.py')
-rw-r--r-- | synapse/metrics/__init__.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py index d7bcad8a8a..943d637459 100644 --- a/synapse/metrics/__init__.py +++ b/synapse/metrics/__init__.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import logging -from resource import getrusage, getpagesize, RUSAGE_SELF +from resource import getrusage, RUSAGE_SELF import functools import os import stat @@ -100,7 +100,6 @@ def render_all(): # process resource usage rusage = None -PAGE_SIZE = getpagesize() def update_resource_metrics(): @@ -113,8 +112,8 @@ resource_metrics = get_metrics_for("process.resource") resource_metrics.register_callback("utime", lambda: rusage.ru_utime * 1000) resource_metrics.register_callback("stime", lambda: rusage.ru_stime * 1000) -# pages -resource_metrics.register_callback("maxrss", lambda: rusage.ru_maxrss * PAGE_SIZE) +# kilobytes +resource_metrics.register_callback("maxrss", lambda: rusage.ru_maxrss * 1024) TYPES = { stat.S_IFSOCK: "SOCK", @@ -131,6 +130,10 @@ def _process_fds(): counts = {(k,): 0 for k in TYPES.values()} counts[("other",)] = 0 + # Not every OS will have a /proc/self/fd directory + if not os.path.exists("/proc/self/fd"): + return counts + for fd in os.listdir("/proc/self/fd"): try: s = os.stat("/proc/self/fd/%s" % (fd)) |