ASD
ASD

Reputation: 4967

php Activity log to see which files are being executed

Is there any way to see active processes in PHP (like which files are being executed)?

Upvotes: 13

Views: 5480

Answers (4)

g01d
g01d

Reputation: 682

The easiest way I've found to determine which files are executing is to install the APC cache. Since the php scripts are cached, it can report the files which have/are executing.

Upvotes: 2

DeveloperChris
DeveloperChris

Reputation: 3448

In linux you can install apachetop. This marvellous tool scans your webserver log files showing you which files are being called it has some excellent metrics like showing which ip's are access which scripts. or which are the most popular scripts and files being called.

Another option is to use lsof which lists open files, but as files are opened and closed rather quickly it may not really help

here is a command to watch all open php files

watch -n1 "lsof | grep '\.php'"

watch -n1 is a command that repeatedly runs a command every second

The command is lsof | grep '\.php'

which means list all open files and show only the ones with a .php in the filename

I have run this on a slow webserver and saw nothing, but I tested it and it does work. It may be that the scripts are being opened and closed so fast that the command misses them.

DC

Upvotes: 2

AJJ
AJJ

Reputation: 7701

If you are profiling/debugging, the Advance PHP Debugger (APD) functions could be what you are looking for, you can call the starting point of your app to have a full call tree including parsed files and executed functions, with cumulative times and file/line locations.

Upvotes: 0

dogmatic69
dogmatic69

Reputation: 7585

active processes is not the same as files being executed. you can use something like htop or top to see the processes running.

get_included_files() will help with the second part http://php.net/manual/en/function.get-included-files.php

Upvotes: 1

Related Questions