On Wed, Mar 26, 2003 at 11:04:08AM -0800, Chris wrote:
> Is there a way to have a Red Hat 7.x machine send an email to a
> predetermined email address when the CPU usage reaches a certain point?
> Sort of like those godawful RaQ servers do, but for standard RH7
> installation. I'd like to have such emails sent to my cell phone with
> server name and CPU usage as reported by 'top' so I know when things get
> hairy ;-)
Off the top of my head - totally untested, not even syntax checked.
#The name of the server
NAME=`hostname`
# Maximum load you want to allow
MY_THRESHOLD="0.5"
# of seconds to wait between load checks.
SECONDS=5
# Loop almost forever.
while (`true`) ; do
# Replace $1 with which ever field of loadavg you want.
load=`cat /proc/loadavg | awk '{print $1}'`
if [ $load -gt $#MY_THRESHOLD ] ; then
mail -s "$NAME $MY_THRESHOLD" [EMAIL PROTECTED]
# If we stay in this loop you'll get a TON of emails
on your cell phone.
exit
fi
sleep $SECONDS
done
--
Jeff Kinz, Open-PC, Emergent Research, Hudson, MA. [EMAIL PROTECTED]
copyright 2003. Use is restricted. Any use is an
acceptance of the offer at http://www.kinz.org/policy.html.
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list