New answers tagged top
You can use iostat for this very purpose. Simply run iostat -y 3600 | grep -A 1 avg-cpu The above command will report each hour the various CPU states (idle, iowait, ecc) and the following grep will extrapolate only the two lines about you care. Obviously, do some tests with lower wait time (eg: 5 seconds) before putting the script into production. EDIT: ...
I'm sure you understand the general method of collecting the data along with the time of the collection and tracking the values over time. The specifics would be quite a complicated script and we're not a script writing service. If you wanted to go down that route you might find sar or iostat are more useful YMMV. However there are better tools than top ...
In my experience with Dreamhost VPS (which I believe to be running Linux-VServer) the top-level CPU usage is possibly from the host, as it appears to report numbers higher than the guest's usage, while the load average and CPU usage per process relates to the guest. This is confusing and based on a experience from a single virtual machine, so take it with a ...
Try this: 1) Start a log with date/time, PHP script, and the PID using getmypid() 2) Then watch your server with top 3) When you see the apache process going high, search for the same date/time and PID in your logs. You should be able to find the problematic script.
Top 50 recent answers are included