wok-next view lm-sensors/stuff/healthd @ rev 20607
perdition: up 2.2
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Apr 19 15:57:59 2018 +0300 (2018-04-19) |
parents | |
children |
line source
1 #!/bin/bash
3 #
4 # /usr/bin/healthd
5 #
7 . /etc/healthd.conf
9 cmd="${ALARM_CMD}"
10 addr="${ADMIN_EMAIL}"
11 slp="${ALARM_SLEEP}"
12 sensors="/usr/bin/sensors"
15 while [ $# -gt 0 ] ; do
16 case "${1}" in
17 -c ) cmd="${2}" ; shift 2 ;;
18 -m ) addr="${2}" ; shift 2 ;;
19 -s ) slp="${2}" ; shift 2 ;;
20 * ) shift 1 ;;
21 esac
22 done
24 case "${ALARM_RESET}" in
25 yes) /usr/bin/sensors > /dev/null
26 ;;
27 no) true
28 ;;
29 esac
31 [ -n "${cmd}" ] && [ -n "$( which -- "${cmd%% *}" )" ] || \
32 [ -n "${addr}" ] || exit 1
34 [ "${slp}" -ge 2 ] || slp=600
36 while true ; do
37 sleep 15
38 message="$( $sensors )"
39 case "$message" in
40 '' ) message='Could not get any sensor values !' ;;
41 *ALARM* ) : ;;
42 * ) message='' ;;
43 esac
44 if [ -n "$message" ]; then
45 if [ -n "${addr}" ]; then
46 echo "$message" | mail -s \
47 "Sensors ALARM detected at host: $( hostname )" \
48 "${addr}"
49 fi
50 [ -z "${cmd}" ] || ${cmd} &
51 sleep ${slp}
52 fi
53 done &