diff --git a/plugins/op_waf/t/ngx_debug.sh b/plugins/op_waf/t/ngx_debug.sh index 87b8ed9ac..3928d9df2 100644 --- a/plugins/op_waf/t/ngx_debug.sh +++ b/plugins/op_waf/t/ngx_debug.sh @@ -2,6 +2,7 @@ export PATH=$PATH:/opt/stap/bin:/opt/stapxx # cd /www/server/mdserver-web/plugins/op_waf/t && bash ngx_debug.sh lua ok +# cd /www/server/mdserver-web/plugins/op_waf/t && bash ngx_debug.sh c ok @@ -27,7 +28,7 @@ then exit fi -pid=`ps -ef|grep openresty | grep -v grep | awk '{print $2}'` +pids=`ps -ef|grep nginx | grep -v grep | awk '{print $2}'` name=$2 @@ -62,25 +63,44 @@ 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 377452 --luajit20 -t 30 >temp.bt - /opt/openresty-systemtap-toolkit/ngx-sample-lua-bt -p $pid --luajit20 -t 30 >temp.bt - # /opt/openresty-systemtap-toolkit/fix-lua-bt temp.bt >t1.bt - /opt/openresty-systemtap-toolkit/fix-lua-bt temp.bt >${name}.bt -elif [ $1 == "c" ]; then - # /opt/openresty-systemtap-toolkit/sample-bt -p 496435 -t 10 -u > t2.bt - /opt/openresty-systemtap-toolkit/sample-bt -p $pid -t 10 -u > ${name}.bt -else - echo "type is only lua/c" - exit -fi - - -# debuginfo-install kernel-3.10.0-1160.80.1.el7.x86_64 -# /opt/FlameGraph/stackcollapse-perf.pl perf.unfold &> perf.folded -# /opt/FlameGraph/flamegraph.pl perf.folded > perf.svg - -/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 +for pid in ${pids[@]}; do + echo $pid + 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}_${pid}.bt + elif [ $1 == "c" ]; then + /opt/openresty-systemtap-toolkit/sample-bt -p $pid -t 10 -u > ${name}_${pid}.bt + else + echo "type is only lua/c" + exit + fi + + /opt/FlameGraph/stackcollapse-stap.pl ${name}_${pid}.bt >${name}_${pid}.cbt + /opt/FlameGraph/flamegraph.pl ${name}_${pid}.cbt >${name}_${pid}.svg + rm -f temp.bt ${name}_${pid}.bt ${name}_${pid}.cbt + echo "strace:$pid, end!" + echo "${name}_${pid}.svg -- make ok" +done + +# if [ $1 == "lua" ]; then +# # /opt/openresty-systemtap-toolkit/ngx-sample-lua-bt -p 377452 --luajit20 -t 30 >temp.bt +# /opt/openresty-systemtap-toolkit/ngx-sample-lua-bt -p $pid --luajit20 -t 30 >temp.bt +# # /opt/openresty-systemtap-toolkit/fix-lua-bt temp.bt >t1.bt +# /opt/openresty-systemtap-toolkit/fix-lua-bt temp.bt >${name}.bt +# elif [ $1 == "c" ]; then +# # /opt/openresty-systemtap-toolkit/sample-bt -p 496435 -t 10 -u > t2.bt +# /opt/openresty-systemtap-toolkit/sample-bt -p $pid -t 10 -u > ${name}.bt +# else +# echo "type is only lua/c" +# exit +# fi + + +# # debuginfo-install kernel-3.10.0-1160.80.1.el7.x86_64 +# # /opt/FlameGraph/stackcollapse-perf.pl perf.unfold &> perf.folded +# # /opt/FlameGraph/flamegraph.pl perf.folded > perf.svg + +# /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