PHP can be configured with DTrace static probes on platforms that
support DTrace Dynamic Tracing.
Configuring PHP for DTrace Static Probes
Refer to external platform specific documentation for enabling
operating system DTrace support. For example, on Oracle Linux
boot a UEK3 kernel and do:
The Provider column values consist of php and
the process id of the currently running PHP process.
If the Apache web server is running, the module name might be, for
example, libphp5.so, and there would be
multiple blocks of listings, one per running Apache process.
The Function column refers to PHP's internal C implementation
function names where each provider is located.
If a PHP process is not running, then no PHP probes will be shown.
DTrace with PHP Example
This example shows the basics of the DTrace D scripting language.
Example #1 all_probes.d for tracing all PHP Static Probes with DTrace
This script uses the -Z option to
dtrace, allowing it to be run when there is no
PHP process executing. If this option were omitted the script
would immediately terminate because it knows none of the probes to
be monitored are in existence.
The script traces all core PHP static probe points throughout the
duration of a running PHP script. Run the D script:
# ./all_probes.d
Run a PHP script or application. The monitoring D script will
output each probe's arguments as it fires.
When monitoring is complete, the D script can be terminated with a
CTRL+C.
On multi-CPU machines the probe ordering might not appear to be
sequential. This depends on which CPU was processing the probes,
and how threads migrate across CPUs. Displaying probe time stamps
will help reduce confusion, for example: