From 8b2de7283a372b8d7d3717e95755389f084bc43d Mon Sep 17 00:00:00 2001 From: David Boucher Date: Wed, 4 Jun 2025 19:40:14 +0200 Subject: [PATCH] enh(generic-snmp): output improved a little with thresholds --- experimental/src/compute/lexer.rs | 4 ++-- experimental/src/compute/mod.rs | 2 +- experimental/src/compute/threshold.rs | 2 +- experimental/src/generic/mod.rs | 7 ++++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/experimental/src/compute/lexer.rs b/experimental/src/compute/lexer.rs index 4585e138f..f26da9fcd 100644 --- a/experimental/src/compute/lexer.rs +++ b/experimental/src/compute/lexer.rs @@ -1,4 +1,4 @@ -use log::{debug, error, trace}; +use log::{error, trace}; use std::str; pub type Spanned = Result<(Loc, Tok, Loc), Error>; @@ -155,7 +155,7 @@ impl<'input> Iterator for Lexer<'input> { } } -mod Test { +mod test { use super::*; fn init() { diff --git a/experimental/src/compute/mod.rs b/experimental/src/compute/mod.rs index b3717da75..561ac1322 100644 --- a/experimental/src/compute/mod.rs +++ b/experimental/src/compute/mod.rs @@ -98,7 +98,7 @@ impl<'a> Parser<'a> { } } -mod Test { +mod test { use super::*; use log::info; use std::collections::HashMap; diff --git a/experimental/src/compute/threshold.rs b/experimental/src/compute/threshold.rs index 318a692c8..2eec48d16 100644 --- a/experimental/src/compute/threshold.rs +++ b/experimental/src/compute/threshold.rs @@ -116,7 +116,7 @@ impl Threshold { } } -mod Test { +mod test { use super::*; #[test] diff --git a/experimental/src/generic/mod.rs b/experimental/src/generic/mod.rs index ac7e56dce..5723409a1 100644 --- a/experimental/src/generic/mod.rs +++ b/experimental/src/generic/mod.rs @@ -85,9 +85,14 @@ pub struct Collect { pub struct Command { collect: Collect, compute: Compute, + #[serde(default = "default_output")] pub output: Output, } +fn default_output() -> Output { + Output::new() +} + #[derive(Debug)] pub struct CmdResult { pub status: Status, @@ -403,7 +408,7 @@ impl Command { } trace!("collect: {:#?}", collect); - println!("metrics: {:#?}", metrics); + trace!("metrics: {:#?}", metrics); let output_formatter = OutputFormatter::new(status, &metrics, &self.output); let output = output_formatter.to_string(); Ok(CmdResult { status, output })