archrelease: copy trunk to extra-x86_64
[arch-packages.git] / lm_sensors / trunk / healthd
blobb1e2fd69992673225fdcd3b85935d9ea63a85a50
1 #!/bin/bash
4 # /usr/bin/healthd
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
27 no) true
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}"
50 [ -z "${cmd}" ] || ${cmd} &
51 sleep ${slp}
53 done &