aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-11-12 15:33:50 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-11-12 15:33:50 +0100
commit0d3fda6ac7623a31bd90bd79ec36cc3fb8514aee (patch)
treeb830f7ddc1171dbe8942047c1420431371e2acf4
parent18ce3106fd6a70b0d8a494d17730217b91e72eac (diff)
downloadmonitoring_custom-0d3fda6ac7623a31bd90bd79ec36cc3fb8514aee.tar.gz
+check_sensors
-rwxr-xr-xcheck_sensors32
1 files changed, 32 insertions, 0 deletions
diff --git a/check_sensors b/check_sensors
new file mode 100755
index 0000000..f0b3650
--- /dev/null
+++ b/check_sensors
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# °C
+WARN=75
+CRIT=85
+
+PERFDATA="|"
+IS_WARN="false"
+IS_CRIT="false"
+
+TEXT=(OK WARNING CRITICAL UNKOWN)
+LEVEL=0
+
+DATA=( $(sensors | \
+ grep "^Core" | \
+ sed -n "s|^Core\s[0-9]\+:\s\++\([0-9]\+\.[0-9]\+\)°C.*$|\1|p" ) )
+
+for (( i=0; i<${#DATA[@]}; i++ )); do
+ (( $(echo "${DATA[$i]} > $WARN" | bc -l ) )) && IS_WARN="true"
+ (( $(echo "${DATA[$i]} > $CRIT" | bc -l ) )) && IS_CRIT="true"
+ PERFDATA+="core_$i=${DATA[$i]},"
+done
+
+echo $IS_CRIT $IS_WARN
+
+[ $IS_WARN = true ] && LEVEL=1
+[ $IS_CRIT = true ] && LEVEL=2
+[ ${#DATA[@]} -eq 0 ] && LEVEL=3
+
+echo "sensors ${TEXT[$LEVEL]}$PERFDATA"
+
+exit $LEVEL