mirror of https://github.com/midoks/mdserver-web
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
838 B
35 lines
838 B
3 years ago
|
#!/bin/sh
|
||
|
|
||
|
if [ $# -ne 3 ]
|
||
|
then
|
||
|
echo "Usage: ./`basename $0` lua/c PID NAME"
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
pid=$2
|
||
|
name=$3
|
||
|
|
||
|
|
||
|
if [ ! -d /opt/openresty-systemtap-toolkit ];then
|
||
|
cd /opt && git clone https://github.com/openresty/openresty-systemtap-toolkit
|
||
|
fi
|
||
|
|
||
|
if [ ! -d /opt/FlameGraph ];then
|
||
|
cd /opt && git clone https://github.com/brendangregg/FlameGraph
|
||
|
fi
|
||
|
|
||
|
if [ $1 == "lua" ]; then
|
||
|
/opt/openresty-systemtap-toolkit/ngx-sample-lua-bt -p $pid --luajit20 -t 30 >temp.bt
|
||
|
/opt/openresty-systemtap-toolkit/fix-lua-bt temp.bt >${name}.bt
|
||
|
elif [ $1 == "c" ]; then
|
||
|
/opt/nginx-systemtap-toolkit/sample-bt -p $pid -t 10 -u > ${name}.bt
|
||
|
else
|
||
|
echo "type is only lua/c"
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
/opt/FlameGraph/stackcollapse-stap.pl ${name}.bt >${name}.cbt
|
||
|
/opt/FlameGraph/flamegraph.pl ${name}.cbt >${name}.svg
|
||
|
rm -f temp.bt ${name}.bt ${name}.cbt
|
||
|
|