From 756c375cff976bbaa5d7649b7b083ae12e54787e Mon Sep 17 00:00:00 2001 From: Raphael Druon Date: Mon, 12 Aug 2024 07:03:29 -0600 Subject: [PATCH] Output stderr to debug --- lustrefs-exporter/src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lustrefs-exporter/src/main.rs b/lustrefs-exporter/src/main.rs index 8ef81e6..aa2b545 100644 --- a/lustrefs-exporter/src/main.rs +++ b/lustrefs-exporter/src/main.rs @@ -18,7 +18,7 @@ use serde::Deserialize; use std::{ borrow::Cow, convert::Infallible, - io::{self, BufReader}, + io::{self, BufRead, BufReader}, net::SocketAddr, }; use tokio::process::Command; @@ -96,6 +96,7 @@ async fn scrape(Query(params): Query) -> Result, Error> { .arg("get_param") .args(["obdfilter.*OST*.job_stats", "mdt.*.job_stats"]) .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) .spawn()?; Ok::<_, Error>(child) @@ -112,6 +113,17 @@ async fn scrape(Query(params): Query) -> Result, Error> { ))?, ); + let reader_stderr = BufReader::new(child.stderr.take().ok_or(io::Error::new( + io::ErrorKind::NotFound, + "stderr missing for lctl jobstats call.", + ))?); + + tokio::task::spawn(async move { + for line in reader_stderr.lines().map_while(Result::ok) { + tracing::debug!("stderr: {}", line); + } + }); + let (_, rx) = lustrefs_exporter::jobstats::jobstats_stream(reader); let stream = ReceiverStream::new(rx)