From 1b97010de83afad032bae24ef4fd0ef78ef9e4c4 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 12 Aug 2020 05:44:33 +0200 Subject: [PATCH] Added key unraid.temperatures to get system temperatures. Note that this only works if you have the Dynamix System Temperature plugin installed. --- .../plugins/zabbix_agent/zabbix_agentd.conf | 1 + .../zabbix_agent/scripts/temperatures.sh | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 files/usr/local/emhttp/plugins/zabbix_agent/scripts/temperatures.sh diff --git a/files/boot/config/plugins/zabbix_agent/zabbix_agentd.conf b/files/boot/config/plugins/zabbix_agent/zabbix_agentd.conf index edd5508..db2893a 100644 --- a/files/boot/config/plugins/zabbix_agent/zabbix_agentd.conf +++ b/files/boot/config/plugins/zabbix_agent/zabbix_agentd.conf @@ -27,3 +27,4 @@ UserParameter=unraid.disk[*],/usr/local/emhttp/plugins/zabbix_agent/scripts/disk UserParameter=unraid.disks.totals,/usr/local/emhttp/plugins/zabbix_agent/scripts/disks.totals.sh UserParameter=unraid.qemu.discovery,/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.discovery.sh UserParameter=unraid.qemu[*],/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.sh "$1" +UserParameter=unraid.temperatures,/usr/local/emhttp/plugins/zabbix_agent/scripts/temperatures.sh \ No newline at end of file diff --git a/files/usr/local/emhttp/plugins/zabbix_agent/scripts/temperatures.sh b/files/usr/local/emhttp/plugins/zabbix_agent/scripts/temperatures.sh new file mode 100644 index 0000000..390d6b2 --- /dev/null +++ b/files/usr/local/emhttp/plugins/zabbix_agent/scripts/temperatures.sh @@ -0,0 +1,37 @@ +#!/bin/bash +result=$( sensors ) +error="$?" +if [ "$error" -gt 0 ]; then + echo '{"error": "sensors is not installed"}' + exit 1 +fi + +echo -n "{" + +# CPU temp +line=$( grep 'CPU Temp:' <<< "$result" ) +error="$?" +echo -n '"cpu": ' +if [ "$error" -eq 0 ]; then + read _ _ temp _ <<< "$line" + temp="${temp#+}" + temp="${temp%°C}" + echo -n "$temp" +else + echo -n "null" +fi + +# MB +line=$(grep 'MB Temp:' <<< "$result" ) +error="$?" +echo -n ', "mainboard": ' +if [ "$error" -eq 0 ]; then + read _ _ temp _ <<< "$line" + temp="${temp#+}" + temp="${temp%°C}" + echo -n "$temp" +else + echo -n "null" +fi + +echo "}"