There is a question that is similar to what I want to know here on server fault: How can I find exactly which PHP scripts are taking up all server resources? but I don't think any of the answers answer my question.
Today I was sent a screenshot by one of my clients. He had no idea what it meant, so he sent it to me to explain it to him. The image was sent by his hosting provider. My client's site is running slow, and I guess he asked the hosting guys why, so they sent him that image. The image appears to be a screenshot of the top command, and it shows that a file is taking up 90%+ of the CPU. I find this really interesting, and would love to know how to do that myself.
As I said, the screenshot appears to be the top command, but when I run top, and get the server busy, I do not get the same kind of result. I make sure that the script I run takes up some CPU with an infinite loop, but all I get is apache2 as the Command that is using up the CPU, while their screenshot shows:
This is what the screenshot looks like:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1234 username 16 -2 134m 26m 7528 R 98 0.2 00:00:50 /usr/bin/php /path/to/file.php
And mine looks like this:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 19632 www-data 20 0 44432 18m 3608 S 27.1 0.9 00:00:82 apache2
Notice how theirs shows /usr/bin/php and the path to the file that is hugging the CPU, but mine just shows apache2, which really tells me nothing useful.
I've always wanted to do this kind of thing and figure out what file is using up the CPU, now, my question is, how do they do that with top? I know I can use a profiler, and in fact, the question I liked to above has two nice suggestions, but I am curious as to how they do it with top.
Thanks in advance.