Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've a remote server running Apache with some websites. Sometimes load average rises too much, and webserver is unresponsive

I think it's caused by apache, but i can't check because ssh session is closed automatically when i log in. I just can solve it by restarting the server (actually, i've to call the provider to restart it manually).

Once it's restarted, I can check on Cacti that load average was too high (more than 100).

Can anyone explain my any way to find and solve the problem? Maybe I need a trigger or something like that to restart Apache when load average rises, I don't know.

Thanks in advanced.

share|improve this question
    
What exactly do you mean by load "average"? Averaged over what time span? Are you sure you don't mean memory usage? –  terdon Feb 4 '13 at 16:57
    
Averaged over 1, 5 and 15 minutes. –  isma Feb 4 '13 at 17:09
    
OK, so this is the output of top? The thing is that a load of 100% should not really be visible to you. I repeat, are you sure this is not an issue of RAM usage? –  terdon Feb 4 '13 at 17:14
    
I don't know exactly where is the issue. Cacti can't monitor activity when it happens. –  isma Feb 4 '13 at 17:16
    
But the load is not expressed in % (I think), it raises until 150 or 200 –  isma Feb 4 '13 at 17:17

1 Answer 1

up vote 0 down vote accepted

The first thing you need to do is monitor what is going on, come back and update your question when you have more details.

Use a small script that will query system and memory load every few seconds and save that info to a file. Perhaps something like this:

#!/bin/sh
while true
do
    echo "-------`date`--------"
    echo "\t\t%MEM\t%CPU"
    ps ax -o comm,%mem,%cpu | sort -nk3 | tail -n 3
    sleep 30
done

The script will print the usage statistics for the three most CPU heavy processes and then for the 3 most memory heavy processes. It will then wait for 30 seconds (you can change that by giving a different number to sleep) and do it all again. Its output looks like this on my system:

$ ./monitor.sh
-------Mon Feb  4 20:00:51 CET 2013--------
                %MEM %CPU
java             9.1  3.6
Xorg             3.3  4.9
firefox          8.1 12.2
        ---     
Xorg             3.3  4.9
firefox          8.1 12.2
java             9.1  3.6

Save this script as monitor.sh and make it executable and run it in the background while redirecting its output to a file:

chmod 744 monitor.sh
./monitor.sh > usage.log &

You can monitor the progress by running tail -f usage.log.

Let this run for a while and check what was going on the next time your server becomes unresponsive. Be careful though, the script is printing out 9 lines of every 30 seconds. If you let it run too long, you will get a pretty big file. Remember to stop it when you have collected the necessary information.

share|improve this answer
    
Just install sysstat, configure it to record activity and try to make sense of what it reports. –  vonbrand Feb 5 '13 at 3:02
    
That looks good. As I said, I can know "when" it became unresponsive, but can't check why. The problem is that it becomes unresponsive once a week (or 2 weeks), so maybe I can't have this script running too long (I'll try to do some log ratation or something like that to avoid the big files, and reduce the ckeck period). Thanks for your answer! I'll try it. Does anyone know if there's any monitor system (Cacti, Nagios,...) where you can check what was running on the server on a past time? –  isma Feb 5 '13 at 10:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.