Patch and Upstart file for healthd.sh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

I want to propose a patch for healthd.sh and also an Upstart init file for it. A patch is for a decreasing of the resource consumption by healthd.sh; it replaces the external commands with the built-in Bash commands. It did not make a huge difference, but it was still useful in my case.

Thank you.
--- a/healthd.sh	1999-02-15 08:42:01.000000000 +0300
+++ b/healthd.sh	2015-02-25 23:43:48.460431783 +0300
@@ -25,7 +25,8 @@
 
 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 @@
 
 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
# Upstart init file. Installation:
# cp --interactive --verbose /usr/share/doc/lm-sensors/examples/daemon/healthd.sh /usr/local/sbin/healthd
# cp --interactive --verbose /usr/share/doc/lm-sensors/examples/daemon/healthd.conf /etc/init/
# sed --in-place '1,7d' /etc/init/healthd.conf
# initctl reload-configuration
# service healthd start

# healthd - shell script daemon, that sends via email alerts of "sensors" utility
#
# This is a simple daemon, which can be used to alert you in the
# event of a hardware health monitoring alarm by sending an
# email to the root.
 
description	"sends via email alerts of sensors utility"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

exec healthd
_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux