Strace 追踪 php 模拟页面执行,打印log

2024-03-25 12:08

本文主要是介绍Strace 追踪 php 模拟页面执行,打印log,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.strace可以追踪某个程序,如果是一个执行文件,是可以用strace进行追踪

strace /usr/local/php/bin/php   test.php


但是我们的系统,是用浏览器登录访问,也就是说有request,然后我们的系统进行初始化,然后才能执行,不然会报错

strace -t -f -o  strace.txt  /usr/local/php/bin/php  backend/web/index.php   >> 22.thml


这个是要报错的


因此我们需要加入这些参数 HTTP_HOST   REQUEST_URI  然后再加入strace就可以了

 HTTP_HOST=10.10.10.252:600 REQUEST_URI=/  strace -t -f -o  strace.txt  /usr/local/php/bin/php  backend/web/index.php   >> 22.thml

然后就可以在strace.txt查看所有的日志,22.html是这个index.php生成的html代码。

strace是蛮好用的,譬如我想看看我的系统加载的config文件,我的配置都是放到了config文件夹下面


HTTP_HOST=10.10.10.252:600 REQUEST_URI=/  strace -t -f  -s 600  /usr/local/php/bin/php  backend/web/index.php  2>&1  | grep /config

直接就可以输出出来所有的配置文件:

我的日志:

[root@grande erp]# HTTP_HOST=10.10.10.252:600 REQUEST_URI=/  strace -t -f  -s 600  /usr/local/php/bin/php  backend/web/index.php  2>&1  | grep /config
11:37:31 read(3, "<?php\n//echo md5(md5('grandbest!c').'admin');\n//exit;\ndefined('YII_DEBUG') or define('YII_DEBUG', true);\ndefined('YII_ENV') or define('YII_ENV', 'dev');   // prod(YII_ENV_PROD=true) , dev(YII_ENV_DEV=true) , test(YII_ENV_TEST=true)\n//global\n\n$active_menu = \"\";\nrequire(__DIR__ . '/../../common/Func.php');\nrequire(__DIR__ . '/../../vendor/autoload.php');\nrequire(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');\nrequire(__DIR__ . '/../../common/config/bootstrap.php');\n\n$config = yii\\helpers\\ArrayHelper::merge(\n    require(__DIR__ . '/../../common/config/main.php'),\n    require(__DIR__ . '/../../co"..., 4096) = 857
11:37:31 lstat("/www/web/develop/erp/backend/web/../../common/config/bootstrap.php", {st_mode=S_IFREG|0777, st_size=659, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/web/../../common/config", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/bootstrap.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/web/../../common/config/main.php", {st_mode=S_IFREG|0777, st_size=1283, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/main.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/web/../../common/config/main-local.php", {st_mode=S_IFREG|0777, st_size=1321, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/main-local.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/web/../config/main.php", {st_mode=S_IFREG|0777, st_size=3175, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/web/../config", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/main.php", O_RDONLY) = 3
11:37:31 open("/www/web/develop/erp/backend/config/../../common/config/custom", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/blog.php", {st_mode=S_IFREG|0744, st_size=27, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/blog.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/cache.php", {st_mode=S_IFREG|0744, st_size=1089, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/cache.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/category.php", {st_mode=S_IFREG|0744, st_size=165, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/category.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/cookie.php", {st_mode=S_IFREG|0744, st_size=158, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/cookie.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/country.php", {st_mode=S_IFREG|0744, st_size=58, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/country.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/currency.php", {st_mode=S_IFREG|0744, st_size=658, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/currency.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/customer.php", {st_mode=S_IFREG|0744, st_size=521, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/customer.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/email.php", {st_mode=S_IFREG|0744, st_size=806, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/email.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/home.php", {st_mode=S_IFREG|0744, st_size=134, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/home.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/payment.php", {st_mode=S_IFREG|0744, st_size=1647, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/payment.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/product.php", {st_mode=S_IFREG|0744, st_size=4286, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/product.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/shipping.php", {st_mode=S_IFREG|0744, st_size=297, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/shipping.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/store.php", {st_mode=S_IFREG|0744, st_size=749, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/store.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/url.php", {st_mode=S_IFREG|0744, st_size=423, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/url.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/params.php", {st_mode=S_IFREG|0777, st_size=61, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/params.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/params-local.php", {st_mode=S_IFREG|0777, st_size=161, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/params-local.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/params.php", {st_mode=S_IFREG|0777, st_size=460, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/params.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/params-local.php", {st_mode=S_IFREG|0777, st_size=18, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/params-local.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/menu.php", {st_mode=S_IFREG|0777, st_size=11502, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/local.php", {st_mode=S_IFREG|0777, st_size=797, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/../../myapp/etc/mongo", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/admin_user.php", {st_mode=S_IFREG|0777, st_size=295, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/base_catalog_category.php", {st_mode=S_IFREG|0744, st_size=505, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/base_catalog_category_product.php", {st_mode=S_IFREG|0744, st_size=328, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/base_catalog_product.php", {st_mode=S_IFREG|0744, st_size=764, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/ids.php", {st_mode=S_IFREG|0744, st_size=352, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/order_email.php", {st_mode=S_IFREG|0777, st_size=1171, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/sync_from_onfancy_log.php", {st_mode=S_IFREG|0744, st_size=355, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_catalog_category.php", {st_mode=S_IFREG|0744, st_size=2208, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_catalog_category_product.php", {st_mode=S_IFREG|0744, st_size=1302, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_catalog_product.php", {st_mode=S_IFREG|0744, st_size=2641, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_category_link_base_category.php", {st_mode=S_IFREG|0744, st_size=397, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_site_body.php", {st_mode=S_IFREG|0744, st_size=272, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_site_update_log.php", {st_mode=S_IFREG|0744, st_size=384, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/../../myapp/etc/modules", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Ebay_Ebayorder.php", {st_mode=S_IFREG|0666, st_size=117, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Adminlogin.php", {st_mode=S_IFREG|0777, st_size=110, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Customer.php", {st_mode=S_IFREG|0777, st_size=106, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Dashboard.php", {st_mode=S_IFREG|0777, st_size=108, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Erpproduct.php", {st_mode=S_IFREG|0744, st_size=132, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Product.php", {st_mode=S_IFREG|0777, st_size=104, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Purchase.php", {st_mode=S_IFREG|0777, st_size=106, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Resource.php", {st_mode=S_IFREG|0777, st_size=106, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Sales.php", {st_mode=S_IFREG|0777, st_size=100, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_System.php", {st_mode=S_IFREG|0777, st_size=102, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_User.php", {st_mode=S_IFREG|0744, st_size=98, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Wish.php", {st_mode=S_IFREG|0777, st_size=106, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Xxapi.php", {st_mode=S_IFREG|0777, st_size=100, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Wish_Wishorder.php", {st_mode=S_IFREG|0777, st_size=117, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/web/../config/main-local.php", {st_mode=S_IFREG|0777, st_size=757, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/main-local.php", O_RDONLY) = 3
11:37:32 access("/www/web/develop/erp/myapp/code/core/Erp/Adminlogin/etc/config.php", F_OK) = -1 ENOENT (No such file or directory)


这篇关于Strace 追踪 php 模拟页面执行,打印log的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/844966

相关文章

【C++】_list常用方法解析及模拟实现

相信自己的力量,只要对自己始终保持信心,尽自己最大努力去完成任何事,就算事情最终结果是失败了,努力了也不留遗憾。💓💓💓 目录   ✨说在前面 🍋知识点一:什么是list? •🌰1.list的定义 •🌰2.list的基本特性 •🌰3.常用接口介绍 🍋知识点二:list常用接口 •🌰1.默认成员函数 🔥构造函数(⭐) 🔥析构函数 •🌰2.list对象

如何在页面调用utility bar并传递参数至lwc组件

1.在app的utility item中添加lwc组件: 2.调用utility bar api的方式有两种: 方法一,通过lwc调用: import {LightningElement,api ,wire } from 'lwc';import { publish, MessageContext } from 'lightning/messageService';import Ca

内核启动时减少log的方式

内核引导选项 内核引导选项大体上可以分为两类:一类与设备无关、另一类与设备有关。与设备有关的引导选项多如牛毛,需要你自己阅读内核中的相应驱动程序源码以获取其能够接受的引导选项。比如,如果你想知道可以向 AHA1542 SCSI 驱动程序传递哪些引导选项,那么就查看 drivers/scsi/aha1542.c 文件,一般在前面 100 行注释里就可以找到所接受的引导选项说明。大多数选项是通过"_

usaco 1.2 Transformations(模拟)

我的做法就是一个一个情况枚举出来 注意计算公式: ( 变换后的矩阵记为C) 顺时针旋转90°:C[i] [j]=A[n-j-1] [i] (旋转180°和270° 可以多转几个九十度来推) 对称:C[i] [n-j-1]=A[i] [j] 代码有点长 。。。 /*ID: who jayLANG: C++TASK: transform*/#include<

maven 编译构建可以执行的jar包

💝💝💝欢迎莅临我的博客,很高兴能够在这里和您见面!希望您在这里可以感受到一份轻松愉快的氛围,不仅可以获得有趣的内容和知识,也可以畅所欲言、分享您的想法和见解。 推荐:「stormsha的主页」👈,「stormsha的知识库」👈持续学习,不断总结,共同进步,为了踏实,做好当下事儿~ 专栏导航 Python系列: Python面试题合集,剑指大厂Git系列: Git操作技巧GO

hdu4431麻将模拟

给13张牌。问增加哪些牌可以胡牌。 胡牌有以下几种情况: 1、一个对子 + 4组 3个相同的牌或者顺子。 2、7个不同的对子。 3、13幺 贪心的思想: 对于某张牌>=3个,先减去3个相同,再组合顺子。 import java.io.BufferedInputStream;import java.io.BufferedReader;import java.io.IOExcepti

【每日一题】LeetCode 2181.合并零之间的节点(链表、模拟)

【每日一题】LeetCode 2181.合并零之间的节点(链表、模拟) 题目描述 给定一个链表,链表中的每个节点代表一个整数。链表中的整数由 0 分隔开,表示不同的区间。链表的开始和结束节点的值都为 0。任务是将每两个相邻的 0 之间的所有节点合并成一个节点,新节点的值为原区间内所有节点值的和。合并后,需要移除所有的 0,并返回修改后的链表头节点。 思路分析 初始化:创建一个虚拟头节点

每日一题|牛客竞赛|四舍五入|字符串+贪心+模拟

每日一题|四舍五入 四舍五入 心有猛虎,细嗅蔷薇。你好朋友,这里是锅巴的C\C++学习笔记,常言道,不积跬步无以至千里,希望有朝一日我们积累的滴水可以击穿顽石。 四舍五入 题目: 牛牛发明了一种新的四舍五入应用于整数,对个位四舍五入,规则如下 12345->12350 12399->12400 输入描述: 输入一个整数n(0<=n<=109 ) 输出描述: 输出一个整数

jenkins 插件执行shell命令时,提示“Command not found”处理方法

首先提示找不到“Command not found,可能我们第一反应是查看目标机器是否已支持该命令,不过如果相信能找到这里来的朋友估计遇到的跟我一样,其实目标机器是没有问题的通过一些远程工具执行shell命令是可以执行。奇怪的就是通过jenkinsSSH插件无法执行,经一番折腾各种搜索发现是jenkins没有加载/etc/profile导致。 【解决办法】: 需要在jenkins调用shell脚

【算法专场】模拟(下)

目录 前言 38. 外观数列 算法分析 算法思路 算法代码 1419. 数青蛙 算法分析 算法思路 算法代码  2671. 频率跟踪器 算法分析 算法思路 算法代码 前言 在前面我们已经讲解了什么是模拟算法,这篇主要是讲解在leetcode上遇到的一些模拟题目~ 38. 外观数列 算法分析 这道题其实就是要将连续且相同的字符替换成字符重复的次数+