Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a pretty typical LAMP server running a web site but sometimes, during the night, resource usage skyrockets and the site becomes unresponsive. There are a lot of logged errors about being unable to connect to MySQL, and the MySQL process gets automatically restarted, according to /var/log/messages ..

But I don't know why. It's not getting high traffic, not even from bots crawling the site. It's not happening at the same time every night, so it doesn't seem to be related to any specific cron job that might be firing off. Is there any way to log what's going on with the system when this happens so I can look at it the next morning?

share|improve this question
possible duplicate of What tool do you use to monitor your servers? – EEAA May 28 '11 at 5:02

Get Munin installed. It will track your system resources (RAM, CPU, Disk), but can also monitor more detailed apache stats if you enable mod_status. By default, Munin just graphs the data it collects, but you can also configure it to alert on threshold exceeded events.

share|improve this answer

Like @Erika said, graphs (like munin) are a must to debug this sort of things. You might also consider running atop to log the top informations.

share|improve this answer

I ran into this same problem about a year ago. My solution was monit

You can set up rules to send off alerts, fire up scripts, whatever. If you're using a hosting provider that provides an API which will allow you to scale up resources when you go down, you could write a script to temporarily increase server resources until load goes back below a certain threshold.

Screenshots here:

share|improve this answer

Install some monitoring software. I use:



MySQL Cacti Templates


That ought to give you a good start towards understanding how your system behaves as a baseline. Look for abnormalities and then figure out a way to detect that condition and alert you going forward. Repeat.

share|improve this answer

Suggestions so far are good, but rather complex if you're just trying to track down the problem you're having. A mixture of sar, atop (with atopsar) and possibly sysshot should get you the information you need without having to configure anything - install them, start the services, sit back and wait while the data is collected.

share|improve this answer

Your Answer


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.