diff options
Diffstat (limited to 'synapse/metrics')
-rw-r--r-- | synapse/metrics/__init__.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py index 75ba248c56..a79fb026d4 100644 --- a/synapse/metrics/__init__.py +++ b/synapse/metrics/__init__.py @@ -119,6 +119,17 @@ rusage = None stats = None fd_counts = None +# In order to report process_start_time_seconds we need to know the machine's +# boot time, because the value in /proc/self/stat is relative to this +boot_time = None +try: + with open("/proc/stat") as _procstat: + for line in _procstat: + if line.startswith("btime "): + boot_time = int(line.split()[1]) +except IOError: + pass + TYPES = { stat.S_IFSOCK: "SOCK", stat.S_IFLNK: "LNK", @@ -218,6 +229,10 @@ process_metrics.register_callback( "max_fds", lambda: _get_max_fds() ) +process_metrics.register_callback( + "start_time_seconds", lambda: boot_time + int(stats[19]) / TICKS_PER_SEC +) + reactor_metrics = get_metrics_for("reactor") tick_time = reactor_metrics.register_distribution("tick_time") pending_calls_metric = reactor_metrics.register_distribution("pending_calls") |