diff --git a/experimental/examples/cpu1.json b/experimental/examples/cpu1.json new file mode 100644 index 000000000..6201ef881 --- /dev/null +++ b/experimental/examples/cpu1.json @@ -0,0 +1,18 @@ +{ + "leaf": { + "name": "cpu", + "output": { + "status": "CPU {idx} usage: {value} %", + "default": "{status}: {count} CPU(s) average usage is {total_cpu_avg} %" + }, + "entries": [ + { "Agregation": { "name": "total_cpu_avg", "op": "Average"}}, + { "Query": { "name": "cpu_{idx}", "oid": "1.3.6.1.2.1.25.3.3.1.2", "query": "Walk" }} + ], + "data": { + "uom": "%", + "min": 0, + "max": 100 + } + } +} diff --git a/experimental/examples/mem.json b/experimental/examples/mem.json new file mode 100644 index 000000000..9f812f54a --- /dev/null +++ b/experimental/examples/mem.json @@ -0,0 +1,74 @@ +{ + "leaf": { + "name": "mem", + "output": { + "header": "{status}: ", + "text": [ + "{count} CPU(s) average usage is {total_cpu_avg} %", + "CPU '{idx}' usage: {value} %" + ] + }, + "entries": [ + { + "Query": { + "name": "used", + "oid": "1.3.6.1.4.1.2021.4.6.0", + "query": "Get" + } + }, + { + "Query": { + "name": "free", + "oid": "1.3.6.1.4.1.2021.4.4.0", + "query": "Get" + } + }, + { + "Query": { + "name": "used_prct", + "oid": "1.3.6.1.4.1.2021.4.14.0", + "query": "Get" + } + }, + { + "Query": { + "name": "buffer", + "oid": "1.3.6.1.4.1.2021.4.13.0", + "query": "Get" + } + }, + { + "Query": { + "name": "cached", + "oid": "1.3.6.1.4.1.2021.4.11.0", + "query": "Get" + } + }, + { + "Query": { + "name": "shared", + "oid": "1.3.6.1.4.1.2021.4.5.0", + "query": "Get" + } + }, + { + "Query": { + "name": "used1", + "oid": "1.3.6.1.4.1.2021.4.3.0", + "query": "Get" + } + }, + { + "Query": { + "name": "used2", + "oid": "1.3.6.1.4.1.2021.4.15.0", + "query": "Get" + } + } + ], + "data": { + "uom": "B", + "min": 0 + } + } +} diff --git a/experimental/examples/new-cpu.json b/experimental/examples/new-cpu.json new file mode 100644 index 000000000..badb30e4b --- /dev/null +++ b/experimental/examples/new-cpu.json @@ -0,0 +1,31 @@ +{ + "collect": { + "snmp": [ + { + "name": "cpu", + "oid": "1.3.6.1.2.1.25.3.3.1.2", + "query": "Walk", // par défaut walk + } + ] + }, + "compute": { + "metrics": [ + { + "name": "core.cpu.usage.percent", + "value": "{cpu}", + "uom": "%", // optional + "min": 0, // optional + "max": 100 // optional + } + ], + "aggregations": [ + { + "name": "avg.cpu.usage.percent", + "value": "Average({cpu})", // si agregation, pas de prefix + "uom": "%", // optional + "min": 0, // optional + "max": 100 // optional + } + ] + } +} diff --git a/experimental/examples/new-disk.json b/experimental/examples/new-disk.json new file mode 100644 index 000000000..fbc85a794 --- /dev/null +++ b/experimental/examples/new-disk.json @@ -0,0 +1,46 @@ +{ + "collect": { + "snmp": [ + { + "name": "disk", + "oid": "1.3.6.1.2.1.25.2.3.1", + "query": "Walk", // par défaut walk + "labels": { + ".3": "label", + ".4": "allocationUnits", + ".5": "size", + ".6": "used" + } + } + ] + }, + "compute": { + "metrics": [ + { + "prefix": "{disk.label}", // par défaut "{idx}" + "name": "disk.usage.percent", + "value": "100 * {disk.used} / {disk.size}", + "uom": "%", // optional + "min": 0, // optional + "max": 100, // optional + }, + { + "name": "disk.usage.bytes", + "value": "{disk.used} * {disk.allocationUnits}", + "uom": "B", // optional + "min": 0, // optional + "max_expr": "{disk.size} * {disk.allocationUnits}" // optional + } + ], + "aggregations": [ + { + "name": "avg.disk.usage.percent", + "value": "Average({metrics.disk.usage.percent})", // si agregation, pas de prefix + "uom": "%", // optional + "min": 0, // optional + "max": 100 // optional + } + ] + } +} + diff --git a/experimental/examples/new-mem.json b/experimental/examples/new-mem.json new file mode 100644 index 000000000..feb981b17 --- /dev/null +++ b/experimental/examples/new-mem.json @@ -0,0 +1,35 @@ +{ + "collect": { + "snmp": [ + { + "name": "total", + "oid": "1.3.6.1.4.1.2021.4.6.0", + "query": "Get", // par défaut walk + }, + { + "name": "free", + "oid": "1.3.6.1.4.1.2021.4.11.0", + "query": "Get", // par défaut walk + } + ] + }, + "compute": { + "metrics": [ + { + "name": "core.mem.usage.percent", + "value": "100 * (1 - {free}/{cpu})", + "uom": "%", // optional + "min": 0, // optional + "max": 100 // optional + }, + { + "name": "avg.cpu.usage.percent", + "value": "Average({cpu})", // si agregation, pas de prefix + "uom": "%", // optional + "min": 0, // optional + "max": 100 // optional + } + ] + } +} + diff --git a/experimental/src/main.rs b/experimental/src/main.rs index 3413dfbc6..e20400f66 100644 --- a/experimental/src/main.rs +++ b/experimental/src/main.rs @@ -52,7 +52,10 @@ fn json_to_command(file_name: &str) -> Result { // Transform content of the file into a string let contents = match fs::read_to_string(file_name) { Ok(ret) => ret, - Err(err) => panic!("Could not deserialize the file, error code: {}", err), + Err(err) => { + println!("erreur: {}", err); + std::process::exit(3); + }, }; let module: Result = serde_json::from_str(&contents.as_str());