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

回到目錄

可以根據關鍵字來搜尋分析器

回到目錄

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

回到目錄