This article explains how to install the latest Systemtap in Ubuntu. And make a fire map
Installing the Debug Image
# Import GPG key
# 16.04 and who
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C8CAB6595FDFF622
#older distributions
#sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01
# set the source
codename=$(lsb_release -c | awk '{print $2}')
sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
deb http://ddebs.ubuntu.com/ ${codename} main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-proposed main restricted universe multiverse
EOF
# update
sudo apt-get update
Install the debug image
sudo apt-get install -y linux-image-$(uname -r)-dbgsymCopy the code
Install the latest version of SystemTap
$ sudo apt-get install -y build-essential zlib1g-dev elfutils libdw-dev gettext
# https://sourceware.org/elfutils/ftp/?C=M; O=D$wget https://sourceware.org/elfutils/ftp/0.170/elfutils-0.170.tar.bz2 $tar xf elfutils - 0.170. Tar..bz2# https://sourceware.org/systemtap/ftp/releases/?C=M; O=D$wget https://sourceware.org/systemtap/ftp/releases/systemtap-3.1.tar.gz $tar ZXF systemtap - 3.1. Tar. Gz $cdSystemtap-3.1 $./configure --prefix=/opt/stap --disable-docs \ --disable-publican --disable-refdocs CFLAGS="-g -O2" \
--with-elfutils=../elfutils-0.170
$ make -j$(getconf _NPROCESSORS_ONLN) && sudo make install
# export STAP_HOME=/opt/stap/
# export PATH=$STAP_HOME:$PATH
# stap -V
Systemtap translator/driver (version 3.1/0.170, non-git sources)
Copyright (C) 2005-2017 Red Hat, Inc. and others
This is free software; see the source forCopying conditions. Tested kernel versions: 2.6.18... 4.10-RC8 enabled Features: PYTHON2 PYTHON3 LIBXML2 NLS READLINECopy the code
Whether the test takes effect
# stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'
Pass 1: parsed user script and 465 library scripts using 77388virt/46648res/5256shr/41840data kb, in 80usr/30sys/333real ms.
Pass 2: analyzed script: 1 probe, 1 function, 7 embeds, 0 globals using 260440virt/231204res/6736shr/224892data kb, in 1680usr/350sys/7050real ms.
Pass 3: translated to C into "/tmp/stap8Lyxq5/stap_e1c4934460a3e749f6deefe95dd50015_2729_src.c" using 260440virt/231404res/6936shr/224892data kb, in 10usr/0sys/5real ms.
Pass 4: compiled C into "stap_e1c4934460a3e749f6deefe95dd50015_2729.ko" in 5260usr/420sys/7185real ms.
Pass 5: starting run.
read performed
Pass 5: run completed in 0usr/20sys/486real ms.Copy the code
Fire chart
Download each Tool package
# git clone https://github.com/openresty/stapxx.git --depth=1 /opt/stapxx
# export STAP_PLUS_HOME=/opt/stapxx
# export PATH=$STAP_PLUS_HOME:$STAP_PLUS_HOME/samples:$PATH
# stap++ -e 'probe begin { println("hello") exit() }'
hello
# git clone https://github.com/openresty/openresty-systemtap-toolkit.git --depth=1 /opt/openresty-systemtap-toolkit
# git clone https://github.com/brendangregg/FlameGraph.git --depth=1 /opt/FlameGraphCopy the code
Fire chart
# /opt/stapxx/samples/lj-lua-stacks.sxx --arg time=120 --skip-badvars -x `ps --no-headers -fC nginx|awk '/worker/ {print $2} '| shuf | head - n 1 ` > / TMP/TMP. The bt (- x is to grasp the pid of the process, detection results output to TMP. The bt)
# /opt/openresty-systemtap-toolkit/fix-lua-bt tmp.bt > / TMP /flame. Bt
# /opt/FlameGraph/stackcollapse-stap.pl /tmp/flame.bt > /tmp/flame.cbt
# /opt/FlameGraph/flamegraph.pl /tmp/flame.cbt > /tmp/flame.svgCopy the code
In order to highlight the effect, it is recommended to use the pressure gauge tool when running stap++ so that sufficient samples can be collected
# ab -n 10000 -c 100 -k http://localhost/Copy the code
Open/TMP /flame. SVG with Chrome firefox as much as possible.
openresty/stapxx
## use stap++ --args xx.sxx to view specific parameters
# stap++ --args /opt/stapxx/samples/lj-lua-stacks.sxx
--arg depth=VALUE (default: 30)
--arg detailed=VALUE (default: 0)
--arg limit=VALUE (default: 1000)
--arg min=VALUE (default: 2)
--arg nointerp=VALUE (default: )
--arg nojit=VALUE (default: )
--arg probe=VALUE (default: timer.profile)
--arg time=VALUE (default: )Copy the code
For script usage, see openresty/stapxx#samples
openresty/openresty-systemtap-toolkit
This series of scripts can be useful for looking at shared memory size, usage, memory leaks, and where, but some scripts require debugging or dependencies to be enabled at compile time. See readme for details.
To use ngx-leaked-pools, use dtrace
$ apt install systemtap-sdt-dev -y
$ ./configure --prefix=/etc/openresty \
--with-dtrace-probesCopy the code
To use ngX-pcrejit, add –with-pcre-opt=-g when compiling openResty
${openResty_home}/nginx/sbin/nginx.old; ${openResty_home}/nginx/sbin/nginx.old; Create a ${openResty_HOME}/nginx/sbin/nginx(new version)
$ kill -USR2 `cat /var/run/nginx.pid`Copy the code
Run ps-FC nginx or ps-FC openresty to check whether the new version is started successfully
If started successfully, both the old and new versions accept requests at this point
through
$ kill -QUIT `cat /var/run/nginx.pid.oldbin`Copy the code
Smooth kill old version
More information please Google, Baidu. Or see the reference links below
Refer to the connection
- Vernacular fire chart – Flame notes
- Build Systemtap- OpenResty official documentation
- Flame Diagrams – OpenReSTY Best Practices
- Systemtap – ubuntu wiki
- openresty/stapxx
- openresty/openresty-systemtap-toolkit
- brendangregg/FlameGraph
- Guo Zhaokun – Nginx start, stop, smooth restart, signal control and smooth upgrade
Blog anjia. Ml / 2017/09/12 /… The nuggets juejin. Cn/post / 684490… Jane books www.jianshu.com/p/008fde883…