blob: 5ffed56816344d1d239f4657a773d88c680a0369 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/bin/bash
#
# /usr/sbin/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 &
|