Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track down PHP script running a given process?

I have a website with a custom script running on a VPS hosting service. All scripts go out through index.php using mod_rewrite and .htaccess for friendly URLs

Something in my script is generating high CPU Usage, as show: CPU usage

When I go and strace a given process I get this that I don't understand:

    setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={90, 0}}, NULL) = 0
    rt_sigaction(SIGPROF, {0x7a6b8f, [PROF], SA_RESTORER|SA_RESTART, 0x2af8ae8742f0}, {0x7a6b8f, [PROF],    SA_RESTORER|SA_RESTART, 0x2af8ae8742f0}, 8) = 0
    rt_sigprocmask(SIG_UNBLOCK, [PROF], NULL, 8) = 0

This is repeated continuously in an infinite loop.

What I need to know is how to track down the exact PHP script causing this problem. Any suggestions?

like image 223
Vinicio Barrantes Avatar asked Jun 28 '12 20:06

Vinicio Barrantes


1 Answers

If you can get the PECL proctitle package into your PHP install, you can use that to make index.php set its process title to the name of the script it handed off to. (The altered process title may or may not show up in particular process table visualizers; use ps if all else fails.)

like image 189
chaos Avatar answered Oct 08 '22 01:10

chaos