From 2f4ac74f521050bf634ee4df8bd03e3b02839fb6 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 13 Oct 2022 00:42:51 +0800 Subject: [PATCH] Create ngx_debug.sh --- plugins/op_waf/t/ngx_debug.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 plugins/op_waf/t/ngx_debug.sh diff --git a/plugins/op_waf/t/ngx_debug.sh b/plugins/op_waf/t/ngx_debug.sh new file mode 100644 index 000000000..c91d6bf52 --- /dev/null +++ b/plugins/op_waf/t/ngx_debug.sh @@ -0,0 +1,34 @@ +#!/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 +