PDA

View Full Version : Load Monitor script



nobaloney
10-09-2010, 11:53 AM
I've cleaned up and re-issued my load-monitor script; you can find it here (http://www.nobaloney.net/downloads/loadmonitors/) (www.nobaloney.net). It's released at no charge under the GNU General Public License, Version 2.

It's designed to give you email warning of a high server load and to optionally reload httpd.

Jeff

bdj
10-09-2010, 12:14 PM
Thanks Jeff for providing it.

If I get it to work in a cron and it will help me with my problem, you'll need to provide donation information :D

nobaloney
10-09-2010, 04:36 PM
You're very welcome. Note on line 61 this script uses a typical Linux restart command for httpd; your OS may require a different command.

Jeff

jmtwl
10-13-2010, 08:20 AM
Thank you very much! Excellent script!

judab2
10-14-2010, 06:34 AM
Very jlasman ,
it is Great script , very usefull

i have added two more functionalities on top of it

a. Monitor DoveCot is up
b. check free memory.

i am attaching the code from my script,
i will be happy if you find it handy and put it in your orginal script.

Best wishes




DOVEUP=`echo QUIT | nc localhost 110 | grep "OK Dovecot DA ready" | wc | awk '{ print $1 }'`
#echo $DOVEUP

if [ "$DOVEUP" == "1" ]; then
echo Dove UP
else
echo Dove Down
echo `date` " Dovecot is down" >>/var/log/scr/alarm/report
# killall -9 -u dovecot
# /etc/init.d/dovecot restart

fi



This is the Code for checking the free mem



# Memory check procedure
FREEMEM=`free -m -o | grep "Mem:" | awk '{ print $4 }'`
echo freemem $FREEMEM
if [ "$FREEMEM" -lt "256" ]; then
echo Memory bad
TIME=`date`
echo $TIME "Free memory" $FREEMEM >> /var/log/scr/alarm/report

sync; echo 3 > /proc/sys/vm/drop_caches


else
echo Memory ok
fi

bdj
10-15-2010, 02:33 AM
Jeff,

I get the following:


TOP[1]=11:29AM: not found
TOP[2]=: not found
TOP[3]=70314: not found
TOP[4]=Swap:: not found
TOP[5]=Mem:: not found
httpd.load.sh: 1: Syntax error: Bad substitution

nobaloney
10-15-2010, 10:37 AM
@judab2:

The linux/unix tradition has always been to have lots of small scripts that do their job well. I'd rather see additional scripts as required, and I'll work on more over time. If you'd like to write one in the meantime but have no place to host it I can host it for you.

@bdj:

The script was written on, and runs on CentOS. If it doesn't run for you, and you're not running CentOS or Red Hat Linux then hopefully someone else can help you. If you are running one of those, then make sure you've downloaded the script, not copied/pasted it from your browser, and that all the lines are correct.

Make sure your file as downloaded, and before any changes, has the correct md5sum:

d0a408e63c676bae6dc62f81f31819aa

Jeff

bdj
10-15-2010, 10:56 AM
Jeff, thanks for the checksum, i've downloaded the script like you said but I try the checksum anyway.

I will try to figure it out myself to make in freebsd compatible.

panosru
11-17-2011, 03:16 PM
Hello Jeff,

I like this script thanks for providing it :)

I have just one question, putting it in crontab is the proper way of using it right?

This is what I have, I guess I'm ok by that right?

root@server:/usr/local/scripts# crontab -l
*/1 * * * * /usr/local/scripts/httpd.load.sh > /dev/null 2>&1

Thanks a lot :)

NoBaloney2
11-18-2011, 12:55 PM
I don't redirect the output. I'm not sure what happens if you do.

*/1 means the same as *; I use */5 and run it every five minutes.

Jeff

panosru
11-18-2011, 12:57 PM
I will change it to */5 then! :) Thank you Jeff :)