From 8e790628bbd51101c7df044937b87eb97d289f95 Mon Sep 17 00:00:00 2001 From: Beu Date: Tue, 13 Apr 2021 23:04:27 +0200 Subject: [PATCH] add lm-sensors --- .../README.md | 2 +- Template Module lm-sensors/README.md | 17 +++ .../Template Module lm-sensors.yaml | 122 ++++++++++++++++++ .../userparameter_sensors.conf | 1 + 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 Template Module lm-sensors/README.md create mode 100644 Template Module lm-sensors/Template Module lm-sensors.yaml create mode 100644 Template Module lm-sensors/userparameter_sensors.conf diff --git a/Template App Nginx by Zabbix agent Enhanced/README.md b/Template App Nginx by Zabbix agent Enhanced/README.md index df4a972..da30a04 100644 --- a/Template App Nginx by Zabbix agent Enhanced/README.md +++ b/Template App Nginx by Zabbix agent Enhanced/README.md @@ -18,4 +18,4 @@ copy the `userparameter_nginx.conf` file in the directory "/etc/zabbix/zabbix_ag ### On your Zabbix WebUI : -In "Configurations" -> "Templates", clic on the "Import" button and load the `module NGINX.yaml` file +In "Configurations" -> "Templates", clic on the "Import" button and load the `Template App Nginx by Zabbix agent Enhanced.yaml` file diff --git a/Template Module lm-sensors/README.md b/Template Module lm-sensors/README.md new file mode 100644 index 0000000..572ff7d --- /dev/null +++ b/Template Module lm-sensors/README.md @@ -0,0 +1,17 @@ +## What is the purpose of this template: + +This template will automatically detect and supervise the temperature sensors of the machines. + +It's optimized to make only one request on the agent, and to proceed the data on the Zabbix server + +## How to setup: + +### On your servers : + +Make sure to install lm-sensors >= 3.5.0 and run the command `sensors-detect` + +copy the `userparameter_sensors.conf` file in the directory "/etc/zabbix/zabbix_agentd.d/" and restart your zabbix agent + +### On your Zabbix WebUI : + +In "Configurations" -> "Templates", clic on the "Import" button and load the `Template Module lm-sensors.yaml` file diff --git a/Template Module lm-sensors/Template Module lm-sensors.yaml b/Template Module lm-sensors/Template Module lm-sensors.yaml new file mode 100644 index 0000000..37e7b32 --- /dev/null +++ b/Template Module lm-sensors/Template Module lm-sensors.yaml @@ -0,0 +1,122 @@ +zabbix_export: + version: '5.2' + date: '2021-04-13T20:45:01Z' + groups: + - + name: Templates + templates: + - + template: 'Template Module lm-sensors' + name: 'Template Module lm-sensors' + description: | + This template will automatically detect and supervise the temperature sensors of the machines. + + It's optimized to make only one request on the agent, and to proceed the data on the Zabbix server + + Important: this template is only compatible with lm-sensors >= 3.5.0 because it uses JSON. + groups: + - + name: Templates + applications: + - + name: Sensors + - + name: Temperatures + - + name: 'Zabbix raw items' + items: + - + name: 'Information about the lm-sensors' + key: sensors + history: 1h + trends: '0' + value_type: TEXT + applications: + - + name: 'Zabbix raw items' + discovery_rules: + - + name: 'Discovery of temperature sensors' + type: DEPENDENT + key: sensors.discovery + delay: '0' + lifetime: 7d + item_prototypes: + - + name: 'Temperature of "{#DEVICE}" - "{#SENSOR}"' + type: DEPENDENT + key: 'sensor-value["{#DEVICE}","{#SENSOR}"]' + delay: '0' + value_type: FLOAT + units: °C + applications: + - + name: Sensors + - + name: Temperatures + preprocessing: + - + type: JSONPATH + parameters: + - '$.[''{#DEVICE}''].[''{#SENSOR}''].[''{#INPUT}'']' + master_item: + key: sensors + trigger_prototypes: + - + expression: '{last()}>={#THRESHOLD}' + name: 'The temperature of the {#DEVICE} - {#SENSOR} sensor is too high' + priority: AVERAGE + graph_prototypes: + - + name: 'Evolution of the Temperature of "{#DEVICE}" - "{#SENSOR}"' + ymin_type_1: FIXED + graph_items: + - + sortorder: '1' + color: 1A7C11 + item: + host: 'Template Module lm-sensors' + key: 'sensor-value["{#DEVICE}","{#SENSOR}"]' + master_item: + key: sensors + preprocessing: + - + type: JAVASCRIPT + parameters: + - | + var parsedvalue = JSON.parse(value); + var output = '['; + for(var device in parsedvalue) { + for(var sensor in parsedvalue[device]) { + input = ''; + max = ''; + crit = ''; + threshold = ''; + for (var index in parsedvalue[device][sensor]) { + if (index.substr(0,4) == "temp" && index.substr(index.length-6,index.length) == "_input") { + input = index; + } else if (index.substr(index.length-4,index.length) == "_max") { + max = parseFloat(parsedvalue[device][sensor][index]); + } else if (index.substr(index.length-5,index.length) == "_crit") { + crit = parseFloat(parsedvalue[device][sensor][index]); + } + } + if (input) { + if (max && crit) { + if (max < crit) { + threshold = max; + } else { + threshold = crit; + } + } else if (max) { + threshold = max; + } else if (crit) { + threshold = crit; + } else { + threshold = "2147483647"; + } + output += '{"{#DEVICE}":"' + device + '","{#SENSOR}":"' + sensor + '","{#INPUT}":"' + input + '","{#THRESHOLD}":"' + threshold + '"},'; + } + } + } + return output.slice(0,-1) + ']'; diff --git a/Template Module lm-sensors/userparameter_sensors.conf b/Template Module lm-sensors/userparameter_sensors.conf new file mode 100644 index 0000000..fa98e9c --- /dev/null +++ b/Template Module lm-sensors/userparameter_sensors.conf @@ -0,0 +1 @@ +UserParameter=sensors,sensors -j -A