diff --git a/crates/ptth_relay/src/scraper_api.rs b/crates/ptth_relay/src/scraper_api.rs index 3bf6512..299ecde 100644 --- a/crates/ptth_relay/src/scraper_api.rs +++ b/crates/ptth_relay/src/scraper_api.rs @@ -216,10 +216,23 @@ async fn metrics ( -> Result , RequestError> { let mut s = String::with_capacity (4 * 1_024); + s.push_str ("# HELP forty_two Forty-two\n"); s.push_str ("# TYPE forty_two counter\n"); s.push_str ("forty_two 42\n"); + #[cfg (target_os = "linux")] + { + if let Some (rss) = tokio::fs::read_to_string ("/proc/self/status").await + .ok () + .and_then (|s| get_rss_from_status (s.as_str ())) + { + s.push_str ("# HELP relay_vm_rss VmRSS of the relay process, in kB\n"); + s.push_str ("# TYPE relay_vm_rss gauge\n"); + s.push_str (format! ("relay_vm_rss {}\n", rss).as_str ()); + } + } + Ok (Response::builder () .body (Body::from (s))?) }