php-fpm debug script
#!/bin/bash
mkdir debug
rm -rf debug/*.trc
additional_strace_args="$1"
MASTER_PID=$(pgrep -f "php-fpm: master process")
summarise=""
#shows total of calls - comment in to get
#summarise="-c"
nohup strace -r $summarise -p $MASTER_PID -ff -o ./debug/master.follow.trc >"debug/master.$MASTER_PID.trc" 2>&1 &
while read -r pid;
do
if [[ $pid != $MASTER_PID ]]; then
#shows total of calls
nohup strace -r $summarise -p "$pid" $additional_strace_args >"debug/$pid.trc" 2>&1 &
fi
done < <(pgrep php-fpm)
read -p "Strace running - press [Enter] to stop"
pkill strace