Analyzer
介绍 用法 Create 用法 示例 Run 用法 示例 List 用法 示例 Search 用法 示例 分析器是用来分析各种程序问题的脚本工具。 每个分析器都有自己的用途。 你可以使用 orxray analyzer 子命令来获取分析器列表,搜索分析器,创建和运行分析器。
目录
介绍
分析器是用来分析各种程序问题的脚本工具。
每个分析器都有自己的用途。
你可以使用 orxray analyzer 子命令来获取分析器列表,搜索分析器,创建和运行分析器。
用法
Usage: orxray analyzer command [OPTIONS]
COMMAND:
create
run
list
search
GLOBAL OPTIONS:
--help
--config specify config file, default is ~/.orxray/config.
Create
用法
这个命令创建一个新的分析器
Usage: orxray analyzer create <name> [OPTIONS]
OPTIONS:
--desc Description.
--ysql YSQL.
--ylang Ylang.
--ylua Ylua.
--opslang Opslang.
GLOBAL OPTIONS:
--help
--config specify config file, default is ~/.orxray/config.
<name>
分析器的名称
--desc "description"
分析器的相关描述
--ysql 'YSQL code'
分析器脚本使用的 YSQL 代码
--ylang 'Ylang code'
分析器脚本使用的 Ylang 代码
--ylua 'ylua code'
分析器脚本使用的 Ylua 代码
--opslang 'opslang code'
分析器脚本使用的 Opslang 代码
示例
使用 YSQL 代码来创建一个分析器,分析器可以打印进程的内存相关信息。
$ orxray analyzer create cli-test --ysql 'select res_mem from proc'
ID: 10075
Run
运行一个你指定的分析器
用法
Usage: orxray analyzer run tool [OPTIONS]
OPTIONS:
-a, --agent integer agent id, please use agent default command to set default agent.
-p, --pid integer pid. If pid is negative, will auto find the pgid of the -pid.
-c, --exe string command.
-t integer sample time in seconds.
--y-var ylang variable. Change the Ylang variable in runtime.
GLOBAL OPTIONS:
--help
--config specify config file, default is ~/.orxray/config.
示例
下面的例子在默认的 agent 上运行 c-on-cpu 分析工具来对进程4502进行分析。
运行完后你可以去访问返回的 URI 网址来查看生成的火焰图。
$ orxray analyzer run c-on-cpu -p 4502
Goto https://your_id.xray.openresty.com/targets/27/history/8885766 for charts.
下面的例子在默认 agent 上运行 c-on-cpu 分析工具来对进程4502 所在的进程组进行分析。 注意这里面传递的是参数是 -4502。
$ orxray analyzer run c-on-cpu -p -4502
Goto https://your_id.xray.openresty.com/targets/27/history/8885767 for charts.
下面的例子分析进程 ID 为 4052 的进程,并传递参数 pcre_unwind=1。
$ orxray analyzer run lj-c-on-cpu -p 4502 --y-var pcre_unwind=1
Goto https://your_id.xray.openresty.com/targets/27/history/8885767 for charts.
List
显示出所有的分析器信息。
用法
Usage: orxray analyzer list
OPTIONS:
-s, --page-size integer page size, 10(default).
GLOBAL OPTIONS:
--help
--config specify config file, default is ~/.orxray/config.
-s, --page-size integer
指定返回数据项的最大数目
示例
$ orxray analyzer list
ID NAME DESCRIPTION
1 count-on-cpu-frames count on cpu frames
2 count-off-cpu-frames count off cpu frames
3 lj-c-on-cpu C-land CPU Flame Graph
7 c-on-cpu C-land CPU Flame Graph
8 c-off-cpu C-land off-CPU Flame Graph
9 kernel-on-cpu kernel-land on-CPU Flame Graph
11 resty-memory Application-Level Memory Usage Breakdown
12 count-lj-newgco-frames count LuaJIT new GC objects frames
14 glibc-chunks Distributions of Memory Chunk Sizes in Glibc Allocator
15 lj-gco-stat Statistics for LuaJIT GC Objects
Search
可以根据关键字来搜索分析器
用法
Usage: orxray tool search WORD [OPTIONS]
OPTIONS:
-s, --page-size integer page size, 10(default).
GLOBAL OPTIONS:
--help
--config specify config file, default is ~/.orxray/config.
-s, --page-size integer
指定返回搜索到的分析器的最大数目
示例
搜索关键字cpu相关的工具
$ orxray analyzer search cpu
count-on-cpu-frames
count-off-cpu-frames
lj-c-on-cpu
lj-lua-on-cpu
lj-c-off-cpu
lj-lua-off-cpu
c-on-cpu
c-off-cpu
kernel-on-cpu
count-lj-c-on-cpu