dtrace php,使用 PHP 和 DTrace

本文介绍了一个使用 DTrace 对 PHP 应用进行详细运行时监控的脚本。该脚本能够跟踪 PHP 的文件编译、错误、异常、请求生命周期及函数调用等事件,有助于深入理解 PHP 应用的执行流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#!/usr/sbin/dtrace -Zs#pragma D option quietphp*:::compile-file-entry

{

printf("PHP compile-file-entry\n");

printf(" compile_file %s\n", copyinstr(arg0));

printf(" compile_file_translated %s\n", copyinstr(arg1));

}php*:::compile-file-return

{

printf("PHP compile-file-return\n");

printf(" compile_file %s\n", copyinstr(arg0));

printf(" compile_file_translated %s\n", copyinstr(arg1));

}php*:::error

{

printf("PHP error\n");

printf(" errormsg %s\n", copyinstr(arg0));

printf(" request_file %s\n", copyinstr(arg1));

printf(" lineno %d\n", (int)arg2);

}php*:::exception-caught

{

printf("PHP exception-caught\n");

printf(" classname %s\n", copyinstr(arg0));

}php*:::exception-thrown

{

printf("PHP exception-thrown\n");

printf(" classname %s\n", copyinstr(arg0));

}php*:::execute-entry

{

printf("PHP execute-entry\n");

printf(" request_file %s\n", copyinstr(arg0));

printf(" lineno %d\n", (int)arg1);

}php*:::execute-return

{

printf("PHP execute-return\n");

printf(" request_file %s\n", copyinstr(arg0));

printf(" lineno %d\n", (int)arg1);

}php*:::function-entry

{

printf("PHP function-entry\n");

printf(" function_name %s\n", copyinstr(arg0));

printf(" request_file %s\n", copyinstr(arg1));

printf(" lineno %d\n", (int)arg2);

printf(" classname %s\n", copyinstr(arg3));

printf(" scope %s\n", copyinstr(arg4));

}php*:::function-return

{

printf("PHP function-return\n");

printf(" function_name %s\n", copyinstr(arg0));

printf(" request_file %s\n", copyinstr(arg1));

printf(" lineno %d\n", (int)arg2);

printf(" classname %s\n", copyinstr(arg3));

printf(" scope %s\n", copyinstr(arg4));

}php*:::request-shutdown

{

printf("PHP request-shutdown\n");

printf(" file %s\n", copyinstr(arg0));

printf(" request_uri %s\n", copyinstr(arg1));

printf(" request_method %s\n", copyinstr(arg2));

}php*:::request-startup

{

printf("PHP request-startup\n");

printf(" file %s\n", copyinstr(arg0));

printf(" request_uri %s\n", copyinstr(arg1));

printf(" request_method %s\n", copyinstr(arg2));

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值