2

I'm looking for a feature that will allow me to see a current status of all php scripts running and showing me how much memory/io/cpu they are consuming at this point.

I have a wordpress website that has a lot of plugins installed in it, and I'm currently having performance issues that I suspect are related to one of the many plugins.

I'm looking for a quick way to check which script/plugin is consuming the most IO/memory/cpu.

1
  • Not sure about the legitimacy of the unexplained downvote for this question, but... Please add more information about your operating system/architecture. There is (AFAIK) nothing built in to PHP to let you do something like this, but it may be possible to do something through the OS, depending heavily on how your server is set up. Commented Dec 8, 2011 at 14:25

3 Answers 3

3

I did up a quick PHP script (very dodgy parsing on it ,but it works, but anyone wanting to make it neater please work away)

<?php
echo (" <h2>Processes : </h2> <br> <center>");
$cmd = `/usr/bin/top -b -n1 `;

//// parse the page //////////////////
$cmd=str_replace("      "," ",$cmd);
$cmd=str_replace("     "," ",$cmd);
$cmd=str_replace("    "," ",$cmd);
$cmd=str_replace("   "," ",$cmd);
$cmd=str_replace("  "," ",$cmd);
$cmd=str_replace(" ","</td><td>",$cmd);
$cmd=str_replace("\n","</td></tr><tr><td>",$cmd);
$cmd=str_replace("<tr><td></td><td>","<tr><td>",$cmd);
$cmd=str_replace("<tr><td>PID","<tr><td COLSPAN=10 height=50></td></tr><tr bgcolor=e0e0e0><td>PID",$cmd);
///////////////////////////////////////

echo '<table width=900 align=middle border=0><tr><td>';
echo $cmd;
echo '</td></tr></table>';
?>
Sign up to request clarification or add additional context in comments.

1 Comment

That's beautiful!
2

You can install the Xdebug extension and use its profiling functions. The profile will show you how much time is spent in each function so you'll probably be able to find the WP plugin that consumes so much time.

1 Comment

+1 Good call, forgot about Xdebug (for which I should be shot)
0

I'm afraid there is no such command or utility that works 'natively' within PHP.

Since you have tagged Apache, please have a look to Apache's Status module: http://httpd.apache.org/docs/2.0/mod/mod_status.html

The output goes like http://www.apache.org/server-status

This of course requires you to have root access to your webserver, but I believe it shows helpful informations. This can show you, which URLs are taking most CPU time. To investigate further you will need a profiler like (mentioned) Xdebug.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.