How to track PHP script execution of a given process?

I have a website with a custom script running on a VPS hosting. All scripts exit via index.php using mod_rewrite and .htaccess for friendly URLs

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

When I go and strace this process, I get this that I do not 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 repeats continuously in an infinite loop.

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

+7
source share
2 answers

If you can get the PECL proctitle package in your PHP installation, you can use this to have index.php set the process header to the script name that it passed. (A modified process header may or may not appear in separate process table visualizers; use ps if all else fails.)

+6
source

Use the getmypid () function in the script. Just dump this to a log file or something to see which one is the script.

EDIT: Use the auto_prepend_file parameter to automatically include this fragment in all of your files:

 php_value auto_prepend_file append.php 
+2
source

All Articles