用的http://php.net/manual/en/features.dtrace.systemtap.php
最下面探针代码
request__startup 和 request__shutdown 有效果
stap -c 'php test2.php' all_probes.stp -vv
输出为
Pass 1: parsed user script and 470 library scripts using 129380virt/42348res/3340shr/39452data kb, in 310usr/30sys/333real ms.
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
focused on module '/usr/local/bin/php' = [0x400000-0x1114b68, bias 0 file /usr/local/bin/php ELF machine |x86_64 (code 62)
Pass 2: analyzed script: 14 probes, 4 functions, 1 embed, 0 globals using 130964virt/44884res/4068shr/41036data kb, in 10usr/0sys/12real ms.
Pass 3: using cached /root/.systemtap/cache/0b/stap_0bce6eae8275f6d1c2bd99436f6a4daf_9524.c
Pass 4: using cached /root/.systemtap/cache/0b/stap_0bce6eae8275f6d1c2bd99436f6a4daf_9524.ko
Pass 5: starting run.
Running /usr/bin/staprun -v -c php test2.php -R /tmp/stap5H9eS2/stap_0bce6eae8275f6d1c2bd99436f6a4daf_9524.ko
staprun:insert_module:191 Module stap_0bce6eae8275f6d1c2bd99436f6a4daf_4195 inserted from file /tmp/stap5H9eS2/stap_0bce6eae8275f6d1c2bd99436f6a4daf_9524.ko
stapio:start_cmd:263 blocking briefly
stapio:stp_main_loop:848 detaching pid 4197
stapio:start_cmd:285 execing target_cmd php test2.php
Probe request__startup
file /home/test2.php
request_uri -
request_method -
Probe request__shutdown
file /home/test2.php
request_uri -
request_method -
stapio:cleanup_and_exit:510 detach=0
stapio:cleanup_and_exit:527 closing control channel
staprun:remove_module:284 Module stap_0bce6eae8275f6d1c2bd99436f6a4daf_4195 removed.
Spawn waitpid result (0x0): 0
Pass 5: run completed in 10usr/30sys/299real ms.
php 代码为
<?php
function test() {
return 1;
}
test();