Skip to content

Commit

Permalink
fix:修复```符号没有换行导致的格式问题 (moonbingbing#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Miss-you authored Mar 9, 2021
1 parent 2ce7787 commit f267f95
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions flame_graph/how.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ Systemtap 执行流程如下:
### 采集数据

* 获取 CPU 异常的 worker 的进程 ID :

```shell
$ ps -ef | grep nginx
```

* 使用 [lj-lua-stacks.sxx](https://github.com/openresty/stapxx#lj-lua-stacks) 抓取栈信息,并用 [fix-lua-bt](https://github.com/openresty/openresty-systemtap-toolkit#fix-lua-bt) 工具处理:

```shell
# making the ./stap++ tool visible in PATH:
$ export PATH=$PWD:$PATH
Expand All @@ -84,10 +87,12 @@ Systemtap 执行流程如下:
获得了统计数据 `a.bt` 后,便可以使用火焰图工具绘制火焰图了

* 使用 [stackcollapse-stap.pl 和 flamegraph.pl](https://github.com/brendangregg/FlameGraph):

```shell
$ ./stackcollapse-stap.pl a.bt > a.cbt
$ ./flamegraph.pl a.cbt > a.svg
```

* a.svg 即是火焰图,拖入浏览器即可:
![problem](../images/flame_graphic_problem.svg)

Expand Down
5 changes: 5 additions & 0 deletions flame_graph/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ $ stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'
```

结果如下:

```shell
Pass 1: parsed user script and 103 library script(s) using 201628virt/29508res/3144shr/26860data kb, in 10usr/190sys/219real ms.
Pass 2: analyzed script: 1 probe(s), 1 function(s), 3 embed(s), 0 global(s) using 296120virt/124876res/4120shr/121352data kb, in 660usr/1020sys/1889real ms.
Expand All @@ -38,6 +39,7 @@ Pass 5: starting run.
read performed
Pass 5: run completed in 20usr/30sys/354real ms.
```

如果出现如上输出表示安装成功。

#### 在 Ubuntu 上的安装方法
Expand All @@ -57,6 +59,7 @@ https://sourceware.org/systemtap/wiki/SystemtapOnUbuntu
https://sourceware.org/git/?p=systemtap.git;a=blob_plain;f=README;hb=HEAD

> 大体上就这几步:
```bash
# 下载依赖……
$ sudo apt install elfutils
Expand All @@ -83,6 +86,7 @@ $ ps -ef | grep nginx (ps:得到类似这样的输出,其中 15010 即使
```

结果如下:

```
hippo 14857 1 0 Jul01 ? 00:00:00 nginx: master process /opt/openresty/nginx/sbin/nginx -p /home/hippo/skylar_server_code/nginx/main_server/ -c conf/nginx.conf
hippo 15010 14857 0 Jul01 ? 00:00:12 nginx: worker process
Expand All @@ -101,6 +105,7 @@ $ ./fix-lua-bt tmp.bt > flame.bt (处理 lj-lua-stacks.sxx 的输出,使其
$ stackcollapse-stap.pl flame.bt > flame.cbt
$ flamegraph.pl flame.cbt > flame.svg
```

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

PS:如果在执行 `lj-lua-stacks.sxx` 的时间周期内(上面的命令是 5 秒), 抓取的 worker 没有任何业务在跑,那么生成的火焰图便没有业务内容。为了让生成的火焰图更有代表性,我们通常都会在抓取的同时进行压测。
3 changes: 2 additions & 1 deletion lua/time_date_function.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@

#### 获取时间示例代码

>示例代码:
示例代码:

```lua
ngx.log(ngx.INFO, ngx.today())
ngx.log(ngx.INFO, ngx.time())
Expand Down

0 comments on commit f267f95

Please sign in to comment.