mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-29 16:45:04 +02:00
enh(generic-snm): uom available in the output
This commit is contained in:
parent
4a20038a42
commit
5a3aa41887
@ -17,7 +17,8 @@ pub struct Metric {
|
||||
pub name: String,
|
||||
pub prefix: Option<String>,
|
||||
pub value: String,
|
||||
uom: Option<String>,
|
||||
#[serde(default = "empty_string")]
|
||||
pub uom: String,
|
||||
pub min_expr: Option<String>,
|
||||
pub min: Option<f64>,
|
||||
pub max_expr: Option<String>,
|
||||
@ -28,6 +29,10 @@ pub struct Metric {
|
||||
pub critical: Option<String>,
|
||||
}
|
||||
|
||||
fn empty_string() -> String {
|
||||
"".to_string()
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Compute {
|
||||
pub metrics: Vec<Metric>,
|
||||
|
@ -17,6 +17,7 @@ use crate::snmp::SnmpResult;
|
||||
pub struct Perfdata<'p> {
|
||||
pub name: String,
|
||||
pub value: f64,
|
||||
pub uom: &'p str,
|
||||
pub min: Option<f64>,
|
||||
pub max: Option<f64>,
|
||||
pub warning: Option<&'p str>,
|
||||
@ -170,7 +171,12 @@ impl Command {
|
||||
}
|
||||
}
|
||||
|
||||
fn execute_collect(&self, target: &str, version: &str, community: &str) -> Vec<SnmpResult> {
|
||||
fn execute_snmp_collect(
|
||||
&self,
|
||||
target: &str,
|
||||
version: &str,
|
||||
community: &str,
|
||||
) -> Vec<SnmpResult> {
|
||||
let mut collect: Vec<SnmpResult> = Vec::new();
|
||||
let mut to_get = Vec::new();
|
||||
let mut get_name = Vec::new();
|
||||
@ -202,7 +208,7 @@ impl Command {
|
||||
}
|
||||
|
||||
pub fn execute(&self, target: &str, version: &str, community: &str) -> Result<CmdResult> {
|
||||
let mut collect = self.execute_collect(target, version, community);
|
||||
let mut collect = self.execute_snmp_collect(target, version, community);
|
||||
|
||||
let mut idx: u32 = 0;
|
||||
let mut metrics = vec![];
|
||||
@ -264,6 +270,7 @@ impl Command {
|
||||
let m = Perfdata {
|
||||
name,
|
||||
value: *item,
|
||||
uom: &metric.uom,
|
||||
min: compute_threshold(i, &min),
|
||||
max: compute_threshold(i, &max),
|
||||
warning: w,
|
||||
@ -297,6 +304,7 @@ impl Command {
|
||||
let m = Perfdata {
|
||||
name,
|
||||
value: *s,
|
||||
uom: &metric.uom,
|
||||
min: compute_threshold(0, &min),
|
||||
max: compute_threshold(0, &max),
|
||||
warning: w,
|
||||
@ -375,6 +383,7 @@ impl Command {
|
||||
let m = Perfdata {
|
||||
name,
|
||||
value: *item,
|
||||
uom: &metric.uom,
|
||||
min,
|
||||
max,
|
||||
warning: w,
|
||||
@ -399,6 +408,7 @@ impl Command {
|
||||
let m = Perfdata {
|
||||
name: name.to_string(),
|
||||
value: *s,
|
||||
uom: &metric.uom,
|
||||
min,
|
||||
max,
|
||||
warning: w,
|
||||
|
@ -99,9 +99,10 @@ impl<'a> OutputFormatter<'a> {
|
||||
.iter()
|
||||
.map(|m| {
|
||||
format!(
|
||||
"{}={};{};{};{};{}",
|
||||
"{}={}{};{};{};{};{}",
|
||||
m.name,
|
||||
float_string(&m.value),
|
||||
m.uom,
|
||||
m.warning.unwrap_or(""),
|
||||
m.critical.unwrap_or(""),
|
||||
match m.min {
|
||||
|
Loading…
x
Reference in New Issue
Block a user