火焰图脚本
#!/bin/bash
PID=`ps -ef | grep /bin/metafs_server(替换成你需要的程序) | grep -v grep | awk '{print $2}'`
if [ ${#PID} -eq 0 ]
then
echo "process not found"
exit -1
fi
echo "1:"
perf record -F 99 -g -p $PID -- sleep 60
echo "2:"
perf script -i perf.data &> perf.unfold
echo "3:"
FlameGraph/stackcollapse-perf.pl perf.unfold &> perf.folded
echo "4:"
FlameGraph/flamegraph.pl perf.folded > perf.svg
rm -rf perf.data* perf.folded perf.unfold