summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2015-02-28 09:11:05 +0000
committerkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2015-02-28 09:11:05 +0000
commit7fe319e469aae48e41bdd03a6cd27810bbe93755 (patch)
tree1097a349efeda2a06b13be69cc6b24a66f17aef8
parentd6d71231212cf07f40f7984f015d472c2c58eabb (diff)
downloadlm-sensors-7fe319e469aae48e41bdd03a6cd27810bbe93755.tar.gz
healthd.sh: Decrease the resource consumption by replacing the
external commands with the built-in bash commands. Contributed by vbooh. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6273 7894878c-1315-0410-8ee3-d5d059ff63e0
-rw-r--r--CHANGES1
-rwxr-xr-xprog/daemon/healthd.sh12
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