mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-12-08 23:03:46 +00:00
47 lines
813 B
Bash
47 lines
813 B
Bash
#!/bin/bash
|
|
|
|
#
|
|
# /usr/sbin/healthd
|
|
#
|
|
|
|
. /etc/conf.d/healthd
|
|
|
|
cmd="${ALARM_CMD}"
|
|
addr="${ADMIN_EMAIL}"
|
|
slp="${ALARM_SLEEP}"
|
|
sensors="/usr/bin/sensors"
|
|
|
|
|
|
while [ $# -gt 0 ] ; do
|
|
case "${1}" in
|
|
-c ) cmd="${2}" ;;
|
|
-m ) addr="${2}" ;;
|
|
-s ) slp="${2}" ;;
|
|
* ) return 1 ;;
|
|
esac
|
|
shift 2
|
|
done
|
|
|
|
[ -n "${cmd}" ] && [ -n "$( which -- "${cmd%% *}" )" ] || \
|
|
[ -n "${addr}" ] || return 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 &
|