openresty火焰图安装

1、下载systemtap安装包并安装

https://sourceware.org/systemtap/ftp/releases/下载最新版的systemtap.tar.gz压缩包

我安装的时候,最新版本是3.2

wget https://sourceware.org/systemtap/ftp/releases/systemtap-3.2.tar.gz --no-check-certificate

解压

./configure

报错1

configure: error: missing elfutils development headers/libraries (install elfutils-devel, libebl-dev, libdw-dev and/or libebl-devel)

yum install elfutils-devel

报错2

configure:
configure: For a private or temporary build of systemtap, we recommend
configure: configuring with a prefix. For example, try
configure: ./configure python='/usr/bin/python' pyexecdir='${exec_prefix}/lib64/python2.6/site-packages' --prefix=/root/systemtap-3.2-9194
configure: Running systemtap uninstalled, entirely out of the build tree,
configure: is not supported.

./configure python='/usr/bin/python' pyexecdir='${exec_prefix}/lib64/python2.6/site-packages' --prefix=/root/systemtap-3.2-9194

make; make install

安装完成之后,在systemtap目录下,执行

stap -ve 'probe begin { log("hello systemtap!") exit() }'

如果提示pass 5: run completed ... 就表示安装成功。

2、下载

该工具包即是用perl生成stap探测脚本并运行的脚本,如果是要抓Lua级别的情况,请使用工具 ngx-sample-lua-bt

wget https://github.com/brendangregg/openresty-systemtap-toolkit/archive/master.zip --no-check-certificate

该工具包中包含多个火焰图生成工具,其中,stackcollapse-stap.pl才是为SystemTap抓取的栈信息的生成工具

wget https://github.com/brendangregg/FlameGraph/archive/master.zip --no-check-certificate

3、测试

ps -ef|grep nginx

查询nginx worker process的进程号

在openresty-systemtap-toolkit下

 

./ngx-sample-lua-bt -p 15010 --luajit20 -t 5 > tmp.bt (-p 是要抓的进程的pid --luajit20|--luajit51 是LuaJIT的版本 -t是探测的时间,单位是秒, 探测结果输出到tmp.bt)

./fix-lua-bt tmp.bt > flame.bt (处理ngx-sample-lua-bt的输出,使其可读性更佳)

在FlameGraph下

./stackcollapse-stap.pl flame.bt > flame.cbt

./flamegraph.pl flame.cbt > flame.svg

如果一切正常,那么会生成flame.svg,这便是火焰图,用浏览器打开即可。

 

转载于:https://www.cnblogs.com/wangzhisdu/p/7779190.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值