From 53d852c9b5f500e23c4521f34228dc3215bce50e Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 28 Feb 2015 09:11:05 +0000 Subject: [PATCH] healthd.sh: Decrease the resource consumption by replacing the external commands with the built-in bash commands. Contributed by vbooh. --- CHANGES | 1 + prog/daemon/healthd.sh | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 9237506f..905e0590 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ SVN HEAD sensors: Add support for temperature min and critical min hysteresis fancontrol: Deal with moving hwmon attributes Fix shell error when FCFANS is not set + healthd: Avoid using external commands sensors-detect: Add detection of ADC128D818 Add detection of AMD family 16h Kabini and Mullins Add detection of ITE IT8620E and IT8623E diff --git a/prog/daemon/healthd.sh b/prog/daemon/healthd.sh index 5986ca64..a17b92f5 100755 --- a/prog/daemon/healthd.sh +++ b/prog/daemon/healthd.sh @@ -25,7 +25,8 @@ PATH="/bin:/usr/bin:/usr/local/bin:${PATH}" ADMIN_EMAIL="root@localhost" -if [ -n "`sensors | grep ALARM`" ] +sensors_state=$(sensors) +if [[ "$sensors_state" =~ 'ALARM' ]] then echo "Pending Alarms on start up! Exiting!" exit @@ -33,10 +34,11 @@ fi while true do - sleep 15 - if [ -n "`sensors | grep ALARM`" ] + read -t 15 -N 0 + sensors_state=$(sensors) + if [[ "$sensors_state" =~ 'ALARM' ]] then - sensors | mail -s "**** Hardware Health Warning ****" $ADMIN_EMAIL - sleep 600 + echo "$sensors_state" | mail -s '**** Hardware Health Warning ****' $ADMIN_EMAIL + read -t 600 -N 0 fi done