Dave Smith wrote:
> down? If so, you can sometimes see useful info being spewed there. This 
> happened to one of my servers, and it was indeed running out of memory. 
> If you see anything about "OOM", that's what's going on.
>
> In my case, Apache 2 was running out of memory because my MaxClients 
> (and related stuff in the apache config) were too high for the amount of 
> RAM I had.
>   

By the way, I wrote a simple shell script and ran it in cron every 5 
minutes to tell me if I was running out of memory, and if so, who were 
the greedy processes. Here's the script for your hacking pleasure:

#!/bin/bash

low_mem_threshold=100
free_mem_mb=`free -m | grep buffers/cache | awk '{print $4}'`

if [ "$free_mem_mb" -lt $low_mem_threshold ]; then

mail -a "From: YOUR_EMAIL_ADDRESS_HERE" -s 'Low memory report' 
YOUR_EMAIL_ADDRESS_HERE << EOM

Memory summary:

`free -m | sed 1d | sed 1d | head -1 | awk '{print "  Total: " $3+$4 " 
MB, Used: " $3 " MB, Free: " $4 " MB"}'`

Top memory eating processes:

`ps -eo vsz,comm,args | sort -nr | grep -v '^ *0' | grep -v VSZ`
EOM

fi


/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to