Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how strace php-fpm process?

Tags:

php

strace

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)
like image 654
tudouya Avatar asked Nov 11 '15 02:11

tudouya


1 Answers

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

strace -f $(pidof php-fpm | sed 's/\([0-9]*\)/\-p \1/g')
like image 192
charles Avatar answered Nov 20 '22 01:11

charles