Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions lustre-collector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,9 @@ pub fn parse_mgs_fs_output(mgs_fs_output: &[u8]) -> Result<Vec<Record>, LustreCo
check_output(mgs_fs_record, state, &params)
}

pub fn parse_recovery_status_output(
recovery_status_output: &[u8],
) -> Result<Vec<Record>, LustreCollectorError> {
let recovery_status = str::from_utf8(recovery_status_output)?;
let recovery_status = recovery_status.trim();

let (recovery_statuses, state) = parser::parse()
.easy_parse(recovery_status)
.map_err(|err| err.map_position(|p| p.translate_position(recovery_status)))?;

let params = recovery_status_parser::params().join(" ");

check_output(recovery_statuses, state, &params)
}

#[cfg(test)]
mod tests {
use crate::{parse_lctl_output, parse_mgs_fs_output, parse_recovery_status_output};
use crate::{parse_lctl_output, parse_mgs_fs_output};

#[test]
fn ex8761_job_stats() {
Expand All @@ -104,14 +89,6 @@ mod tests {
insta::assert_debug_snapshot!(expected);
}

#[test]
fn test_parse_recovery_status_output() {
let xs = include_bytes!("./fixtures/recovery-multiple.txt");
let expected = parse_recovery_status_output(xs).unwrap();

insta::assert_debug_snapshot!(expected);
}

#[test]
fn test_parse_mgs_fs_output() {
let xs = include_bytes!("./fixtures/mgs-fs.txt");
Expand Down
26 changes: 1 addition & 25 deletions lustre-collector/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use clap::{Arg, ValueEnum, value_parser};
use lustre_collector::{
error::LustreCollectorError, mgs::mgs_fs_parser, parse_lctl_output, parse_lnetctl_global_show,
parse_lnetctl_output, parse_lnetctl_stats, parse_mgs_fs_output, parse_recovery_status_output,
parser, recovery_status_parser, types::Record,
parse_lnetctl_output, parse_lnetctl_stats, parse_mgs_fs_output, parser, types::Record,
};
use std::{
fmt, panic,
Expand Down Expand Up @@ -66,15 +65,6 @@ fn get_lctl_mgs_fs_output() -> Result<Vec<u8>, LustreCollectorError> {
Ok(r.stdout)
}

fn get_recovery_status_output() -> Result<Vec<u8>, LustreCollectorError> {
let r = Command::new("lctl")
.arg("get_param")
.args(recovery_status_parser::params())
.output()?;

Ok(r.stdout)
}

fn get_lnetctl_stats_output() -> Result<Vec<u8>, LustreCollectorError> {
let r = Command::new("lnetctl").arg("stats").arg("show").output()?;

Expand Down Expand Up @@ -150,14 +140,6 @@ fn run() -> Result<(), LustreCollectorError> {
Ok(lnetctl_global_record)
});

let recovery_status_handle =
thread::spawn(move || -> Result<Vec<Record>, LustreCollectorError> {
let recovery_status_output = get_recovery_status_output()?;
let recovery_statuses = parse_recovery_status_output(&recovery_status_output)?;

Ok(recovery_statuses)
});

let lnetctl_net_show_output = Command::new("lnetctl")
.args(["net", "show", "-v", "4"])
.output()
Expand All @@ -176,11 +158,6 @@ fn run() -> Result<(), LustreCollectorError> {
Err(e) => panic::resume_unwind(e),
};

let mut recovery_status_records = match recovery_status_handle.join() {
Ok(r) => r.unwrap_or_default(),
Err(e) => panic::resume_unwind(e),
};

let mut lnetctl_stats_record = match lnetctl_stats_handle.join() {
Ok(r) => r.unwrap_or_default(),
Err(e) => panic::resume_unwind(e),
Expand All @@ -193,7 +170,6 @@ fn run() -> Result<(), LustreCollectorError> {

lctl_record.append(&mut lnet_record);
lctl_record.append(&mut mgs_fs_record);
lctl_record.append(&mut recovery_status_records);
lctl_record.append(&mut lnetctl_stats_record);
lctl_record.append(&mut lnetctl_global_show_record);

Expand Down

This file was deleted.

Loading