root/lm-sensors/trunk/prog/daemon/healthd.sh

Revision 229, 1.2 KB (checked in by phil, 13 years ago)

(Phil) Added my little daemon program. For the record, here's some
features of it:

- As long as the 'sensors' program works correctly, healthd.sh is compatible

with any hardware.

- Very low loading. Just sleeps (like me) most of the time.

- Easily customizable (very simple and short script).

Todo's/wants:

- Syslogging? I couldn't figure out how to syslog from bash shell (yet).

- After one test, it failed to be automatically 'spawned' from a rc.local

script. I did "healthd.sh &", but that didn't seem to work. Ideas?

- a history utility for making pretty plots and such.

- Written in 'C' for better functionality and efficiency?

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/bin/bash
2#
3# healthd --    This is a simple daemon which can be used to alert you in the
4#               event of a hardware health monitoring alarm by sending an
5#               email to the value of ADMIN_EMAIL (defined below).
6#
7# To Use  --    Simply start the daemon from a shell (may be backgrounded)
8#
9# Other details -- Checks status every 15 seconds.  Sends warning emails every
10#                  ten minutes during alarm until the alarm is cleared.
11#                  It won't start up if there is a pending alarm on startup.
12#                  Very low loading on the machine (sleeps almost all the time).
13#                  This is just an example.  It works, but hopefully we can
14#                  get something better written. :')
15#
16# Requirements -- grep, mail, sensors, bash
17#                 (You may need to alter the PATH, but probably not.)
18#
19# Written & Copyrighten by Philip Edelbrock, 1999.
20#
21# Version: 1.0.0
22#
23
24PATH="/bin:/usr/bin:/usr/local/bin:${PATH}"
25
26ADMIN_EMAIL="root@localhost"
27
28if [ -n "`sensors | grep ALARM`" ]
29then
30        echo "Pending Alarms on start up!  Exiting!"
31        exit
32fi
33
34while true
35do
36 sleep 15
37 if [ -n "`sensors | grep ALARM`" ]
38 then
39        sensors | mail -s "**** Hardware Health Warning ****"  $ADMIN_EMAIL
40        sleep 600
41 fi
42done
Note: See TracBrowser for help on using the browser.