how strace php-fpm process?

Deadly 提交于 2019-12-06 06:20:31

问题


I am using nginx+php-fpm for php environment and I want to strace the php script execute,but there are many php-fpm worker, so if how can I know which php-fpm worker is handling the script?
if I should monitor all the php-fpm worker,example is as following:

additional_strace_args="$1"

MASTER_PID=$(ps auwx | grep php-fpm | grep -v grep | grep 'master process'  | cut -d ' ' -f 6)

while read -r pid;
do
    if [[ $pid != $MASTER_PID ]]; then
        nohup strace -r -p "$pid" $additional_strace_args >"$pid.trc" 2>&1 &
    fi
done < <(pgrep php-fpm)

回答1:


You can use the -f flag to trace child processes like this:

strace -f $(pidof php-fpm | sed 's/\([0-9]*\)/\-p \1/g')


来源:https://stackoverflow.com/questions/33643131/how-strace-php-fpm-process

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!