summaryrefslogtreecommitdiff
path: root/lm_sensors/healthd
diff options
context:
space:
mode:
authorsrv <enmanuel.saravia.externo@pandero.com.pe>2025-05-05 15:29:27 -0500
committersrv <enmanuel.saravia.externo@pandero.com.pe>2025-05-05 15:29:27 -0500
commit81555e3bd23c74ce915d246ca51fa65d84c22ae7 (patch)
tree1ba136af6b87426d37d010866b5cdac110eaeaa8 /lm_sensors/healthd
First commitdevelop
Diffstat (limited to 'lm_sensors/healthd')
-rw-r--r--lm_sensors/healthd53
1 files changed, 53 insertions, 0 deletions
diff --git a/lm_sensors/healthd b/lm_sensors/healthd
new file mode 100644
index 0000000..b1e2fd6
--- /dev/null
+++ b/lm_sensors/healthd
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+#
+# /usr/bin/healthd
+#
+
+. /etc/healthd.conf
+
+cmd="${ALARM_CMD}"
+addr="${ADMIN_EMAIL}"
+slp="${ALARM_SLEEP}"
+sensors="/usr/bin/sensors"
+
+
+while [ $# -gt 0 ] ; do
+ case "${1}" in
+ -c ) cmd="${2}" ; shift 2 ;;
+ -m ) addr="${2}" ; shift 2 ;;
+ -s ) slp="${2}" ; shift 2 ;;
+ * ) shift 1 ;;
+ esac
+done
+
+case "${ALARM_RESET}" in
+ yes) /usr/bin/sensors > /dev/null
+ ;;
+ no) true
+ ;;
+esac
+
+[ -n "${cmd}" ] && [ -n "$( which -- "${cmd%% *}" )" ] || \
+ [ -n "${addr}" ] || exit 1
+
+[ "${slp}" -ge 2 ] || slp=600
+
+while true ; do
+ sleep 15
+ message="$( $sensors )"
+ case "$message" in
+ '' ) message='Could not get any sensor values !' ;;
+ *ALARM* ) : ;;
+ * ) message='' ;;
+ esac
+ if [ -n "$message" ]; then
+ if [ -n "${addr}" ]; then
+ echo "$message" | mail -s \
+ "Sensors ALARM detected at host: $( hostname )" \
+ "${addr}"
+ fi
+ [ -z "${cmd}" ] || ${cmd} &
+ sleep ${slp}
+ fi
+done &