首页 > Linux操作系统 > Linux操作系统 > CPU高跟踪--strace
strace -p 15427
进程时间花在哪里?
strace -c -p 11084
跟踪命令执行过程
strace -c >/dev/null ls
追踪mysql执行语句
# strace -f -F -ff -o mysqld-strace -s 1024 -p mysql_pid
# find ./ -name "mysqld-strace*" -type f -print |xargs grep -n "SELECT.*FROM"
或
strace -p 5034
vi whatis.sh
#!/bin/bash
# This script is from http://poormansprofiler.org/
nsamples=1
sleeptime=0
pid=$(pidof $1)
for x in $(seq 1 $nsamples)
do
gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid
sleep $sleeptime
done | \
awk '
BEGIN { s = ""; }
/^Thread/ { print s; s = ""; }
/^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
END { print s }' | \
sort | uniq -c | sort -r -n -k 1,1
whatis.sh mysqld
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/91975/viewspace-1760824/ ,如需转载,请注明出处,否则将追究法律责任。