简体   繁体   中英

how strace php-fpm process?

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)

您可以使用-f标志来跟踪这样的子进程:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM