Load Spike Monitor
Below is a script that can be used to send a plethora of information to an email address when a LINUX computer/server experiences a specific load average. The instructions are found within; make sure to set your email address, commands to send, etc.
If you want CPU temperatures and whatever else, you can add that. You'll see a commented out option for "ipmitool sdr type Temp" which requires you to install impitools. Also, another commented out line using "lynx" would send server-status information from Apache so long as it's enabled in httpd.conf.
#!/bin/bash
# Prints out output for PS and whatever else you want emailed to you should
# your server have issues. ie: apache server-status, uptime, etc...
#
# Just modify and add a cronjob. I recommend every 3 minutes.
# Define Logfile
LOGFILE=/var/log/load_kill_log
# Define and log the process causing the load at the time.
PSFILE=/var/log/ps_log
# Obtain the server load
loadavg=`uptime |cut -d , -f 4|cut -d : -f 2`
thisloadavg=`echo $loadavg|awk -F \. '{print $1}'`
# Set the threshold load minimum where report generates.
# Example: currently a load >10 will have the report generate.
if [ "$thisloadavg" -ge "10" ]; then
date >> $PSFILE
ps auxfww >> $PSFILE
date >> $LOGFILE
# Issue the command of choice. This can be any shell command.
touch /tmp/killphp.txt
ps auxfww >> /tmp/killphp.txt
# ipmitool sdr type Temp >> /tmp/killphp.txt
# lynx --dump http://website.tld/server-status >> /tmp/killphp.txt
# Send Mail To Systems Admins When Killall Executes.
SUBJECT="load overload"
TO="youremail@address.tld"
# This is a temp file created for the email message....
MESSAGE="/tmp/killphp.txt"
echo "server has high load right now." >> $MESSAGE
echo "Time: `date`" >> $MESSAGE
mail -s "$SUBJECT" "$TO" < $MESSAGE
rm $MESSAGE
fi