mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-09-26 03:08:39 +02:00
enh(generic-snmp): output is read from the json file now
This commit is contained in:
parent
8a355dcfeb
commit
ad6dc52dba
@ -22,7 +22,8 @@
|
|||||||
"value": "100 * {disk.used} / {disk.size}",
|
"value": "100 * {disk.used} / {disk.size}",
|
||||||
"uom": "%",
|
"uom": "%",
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 100
|
"max": 100,
|
||||||
|
"output": "{prefix}: {metrics.value}% used"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prefix": "{disk.label}",
|
"prefix": "{disk.label}",
|
||||||
@ -42,6 +43,16 @@
|
|||||||
"max": 100
|
"max": 100
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"ok": "Disk usage OK: {aggregations.avg.disk.usage.percent}% used",
|
||||||
|
"detail_ok": false,
|
||||||
|
"warning": "Disk usage WARNING:",
|
||||||
|
"detail_warning": true,
|
||||||
|
"critical": "Disk usage CRITICAL:",
|
||||||
|
"detail_critical": true,
|
||||||
|
"instance_separator": " - ",
|
||||||
|
"metric_separator": ", "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
"name": "disk",
|
"name": "disk",
|
||||||
"oid": "1.3.6.1.2.1.25.2.3.1",
|
"oid": "1.3.6.1.2.1.25.2.3.1",
|
||||||
"query": "Walk", // par défaut walk
|
"query": "Walk",
|
||||||
"labels": {
|
"labels": {
|
||||||
".3": "label",
|
".3": "label",
|
||||||
".4": "allocationUnits",
|
".4": "allocationUnits",
|
||||||
@ -17,30 +17,42 @@
|
|||||||
"compute": {
|
"compute": {
|
||||||
"metrics": [
|
"metrics": [
|
||||||
{
|
{
|
||||||
"prefix": "{disk.label}", // par défaut "{idx}"
|
"prefix": "{disk.label}",
|
||||||
"name": "disk.usage.percent", // le nom final est `prefix`#`name`
|
"name": "disk.usage.percent",
|
||||||
"value": "100 * {disk.used} / {disk.size}",
|
"value": "100 * {disk.used} / {disk.size}",
|
||||||
"uom": "%", // optional
|
"uom": "%",
|
||||||
"min": 0, // optional
|
"min": 0,
|
||||||
"max": 100, // optional
|
"max": 100,
|
||||||
|
"output": "{prefix}: {metrics.value}% used" // optional : displayed if output. Default value: "{metrics.prefix}: {value}{metrics.uom}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"prefix": "{disk.label}",
|
||||||
"name": "disk.usage.bytes",
|
"name": "disk.usage.bytes",
|
||||||
"value": "{disk.used} * {disk.allocationUnits}",
|
"value": "{disk.used} * {disk.allocationUnits}",
|
||||||
"uom": "B", // optional
|
"uom": "B",
|
||||||
"min": 0, // optional
|
"min": 0,
|
||||||
"max_expr": "{disk.size} * {disk.allocationUnits}" // optional
|
"max_expr": "{disk.size} * {disk.allocationUnits}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aggregations": [
|
"aggregations": [
|
||||||
{
|
{
|
||||||
"name": "avg.disk.usage.percent",
|
"name": "avg.disk.usage.percent",
|
||||||
"value": "Average({metrics.disk.usage.percent})", // si agregation, pas de prefix
|
"value": "Average({metrics.disk.usage.percent})",
|
||||||
"uom": "%", // optional
|
"uom": "%",
|
||||||
"min": 0, // optional
|
"min": 0,
|
||||||
"max": 100 // optional
|
"max": 100
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"ok": "Disk usage OK: {aggregations.avg.disk.usage.percent}% used", // optional: default value: "Everything is OK"
|
||||||
|
"detail_ok": False, // optional: default value: False, if True, metrics are concatenated to the output
|
||||||
|
"warning": "Disk usage WARNING:", // optional: default value: "WARNING:"
|
||||||
|
"detail_warning": True, // optional: default value: True
|
||||||
|
"critical": "Disk usage CRITICAL:", // optional: default value: "CRITICAL:"
|
||||||
|
"detail_critical": True, // optional: default value: True
|
||||||
|
"instance_separator": " - ", // optional: default value: " - "
|
||||||
|
"metric_separator": ", ", // optional: default value: ", "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,10 +80,55 @@ pub struct Collect {
|
|||||||
snmp: Vec<Snmp>,
|
snmp: Vec<Snmp>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
pub struct Output {
|
||||||
|
#[serde(default = "default_ok")]
|
||||||
|
ok: String,
|
||||||
|
#[serde(default = "default_detail_ok")]
|
||||||
|
detail_ok: bool,
|
||||||
|
#[serde(default = "default_warning")]
|
||||||
|
warning: String,
|
||||||
|
#[serde(default = "default_detail_warning")]
|
||||||
|
detail_warning: bool,
|
||||||
|
#[serde(default = "default_critical")]
|
||||||
|
critical: String,
|
||||||
|
#[serde(default = "default_detail_critical")]
|
||||||
|
detail_critical: bool,
|
||||||
|
#[serde(default = "default_instance_separator")]
|
||||||
|
instance_separator: String,
|
||||||
|
#[serde(default = "default_metric_separator")]
|
||||||
|
metric_separator: String,
|
||||||
|
}
|
||||||
|
fn default_ok() -> String {
|
||||||
|
"Everything is OK".to_string()
|
||||||
|
}
|
||||||
|
fn default_detail_ok() -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
fn default_warning() -> String {
|
||||||
|
"WARNING: ".to_string()
|
||||||
|
}
|
||||||
|
fn default_detail_warning() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
fn default_critical() -> String {
|
||||||
|
"CRITICAL: ".to_string()
|
||||||
|
}
|
||||||
|
fn default_detail_critical() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
fn default_instance_separator() -> String {
|
||||||
|
" - ".to_string()
|
||||||
|
}
|
||||||
|
fn default_metric_separator() -> String {
|
||||||
|
", ".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct Command {
|
pub struct Command {
|
||||||
collect: Collect,
|
collect: Collect,
|
||||||
compute: Compute,
|
compute: Compute,
|
||||||
|
output: Output,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -252,7 +297,8 @@ impl Command {
|
|||||||
panic!("A label must be a string");
|
panic!("A label must be a string");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let current_status = compute_status(*item, &metric.warning, &metric.critical)?;
|
let current_status =
|
||||||
|
compute_status(*item, &metric.warning, &metric.critical)?;
|
||||||
status = worst(status, current_status);
|
status = worst(status, current_status);
|
||||||
let w = match metric.warning {
|
let w = match metric.warning {
|
||||||
Some(ref w) => Some(w.as_str()),
|
Some(ref w) => Some(w.as_str()),
|
||||||
@ -361,7 +407,8 @@ impl Command {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let current_status = compute_status(item, &metric.warning, &metric.critical)?;
|
let current_status =
|
||||||
|
compute_status(item, &metric.warning, &metric.critical)?;
|
||||||
status = worst(status, current_status);
|
status = worst(status, current_status);
|
||||||
let w = match metric.warning {
|
let w = match metric.warning {
|
||||||
Some(ref w) => Some(w.as_str()),
|
Some(ref w) => Some(w.as_str()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user