diff --git a/crates/ptth_relay/src/scraper_api.rs b/crates/ptth_relay/src/scraper_api.rs index 004118c..3bf6512 100644 --- a/crates/ptth_relay/src/scraper_api.rs +++ b/crates/ptth_relay/src/scraper_api.rs @@ -249,6 +249,20 @@ pub async fn handle ( } } +fn get_rss_from_status (proc_status: &str) -> Option +{ + use std::str::FromStr; + + for line in proc_status.lines () { + if let Some (rest) = line.strip_prefix ("VmRSS:\t").and_then (|s| s.strip_suffix (" kB")) + { + return u64::from_str (rest.trim_start ()).ok (); + } + } + + None +} + #[cfg (test)] mod tests { use std::{ @@ -425,4 +439,11 @@ mod tests { }); } + + #[test] + fn rss () { + let input = "VmHWM: 584 kB\nVmRSS: 584 kB\nRssAnon: 68 kB\n"; + + assert_eq! (get_rss_from_status (input), Some (584)); + } }