From 5a2a35720ac899ad49b1506c58eb34819e125a6d Mon Sep 17 00:00:00 2001 From: evan Adam Date: Fri, 13 Jun 2025 21:25:47 +0200 Subject: [PATCH] fix(generic-snmp): remove threshold_suffix I don't remember why it was created, and i think we can use the name to point threshold ? --- experimental/src/compute/mod.rs | 2 -- experimental/src/generic/mod.rs | 20 ++++---------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/experimental/src/compute/mod.rs b/experimental/src/compute/mod.rs index 475da4f14..2bbcb6381 100644 --- a/experimental/src/compute/mod.rs +++ b/experimental/src/compute/mod.rs @@ -22,8 +22,6 @@ pub struct Metric { pub min: Option, pub max_expr: Option, pub max: Option, - #[serde(rename = "threshold-suffix")] - pub threshold_suffix: Option, pub warning: Option, pub critical: Option, } diff --git a/experimental/src/generic/mod.rs b/experimental/src/generic/mod.rs index 27a774fed..89272e6bd 100644 --- a/experimental/src/generic/mod.rs +++ b/experimental/src/generic/mod.rs @@ -121,10 +121,7 @@ impl Command { self.compute .metrics .iter_mut() - .find(|metric| match &metric.threshold_suffix { - Some(suffix) => suffix == name, - None => false, - }) + .find(|metric| &metric.name == name) { debug!("Adding warning to metric {}", metric.name); metric.warning = Some(value); @@ -132,10 +129,7 @@ impl Command { if let Some(metric) = aggregations .iter_mut() - .find(|metric| match &metric.threshold_suffix { - Some(suffix) => suffix == name, - None => false, - }) + .find(|metric| &metric.name == name) { debug!("Adding warning to aggregation metric {}", metric.name); metric.warning = Some(value); @@ -148,10 +142,7 @@ impl Command { self.compute .metrics .iter_mut() - .find(|metric| match &metric.threshold_suffix { - Some(suffix) => suffix == name, - None => false, - }) + .find(|metric| &metric.name == name) { metric.critical = Some(value); debug!("Adding critical to metric {}", metric.name); @@ -159,10 +150,7 @@ impl Command { if let Some(metric) = aggregations .iter_mut() - .find(|metric| match &metric.threshold_suffix { - Some(suffix) => suffix == name, - None => false, - }) + .find(|metric| &metric.name == name) { debug!("Adding critical to aggregation metric {}", metric.name); metric.critical = Some(value);