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?