首批通过分布式安全可靠测评,为关键业务系统打造
ASH报告收集
更新时间:2026-04-13 17:11:17
本文适用于独立部署 obdiag 的场景,使用 obdiag gather ash 命令可以一键收集ash报告。
如果是 obd 部署的集群,可直接通过 obd 侧诊断命令组对所选集群进行信息收集,详细命令可参考 诊断工具命令组。
使用说明
obdiag gather ash [options]
获取 ASH 相关信息需要查询 GV$ACTIVE_SESSION_HISTORY 视图获取。
选项说明如下:
| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
|---|---|---|---|---|
| --from | 否 | string | 默认为空 | 采样收集的开始时间,格式为: yyyy-mm-dd hh:mm:ss。
说明若使用的 obdiag 为 V2.0.0 之前版本,配置该选项时无需加引号,否则会报错。V2.0.0 及之后版本不再限制配置该选项时是否加引号。 |
| --to | 否 | string | 默认为空 | 采样收集的结束时间,格式为: yyyy-mm-dd hh:mm:ss。
说明若使用的 obdiag 为 V2.0.0 之前版本,配置该选项时无需加引号,否则会报错。V2.0.0 及之后版本不再限制配置该选项时是否加引号。 |
| --trace_id | 否 | string | 默认为空 | 待采样 SQL 的 TRACE_ID,不填或填 NULL 则表示不限制 TRACE_ID。 |
| --sql_id | 否 | string | 默认为空 | 待采样 SQL 的 SQL_ID,不填或填 NULL 则表示不限制 SQL_ID。 |
| --wait_class | 否 | string | 默认为空 | 待采样的事件类型。WAIT_CLASS 取值参考 GV$ACTIVE_SESSION_HISTORY.WAIT_CLASS 字段的取值,不填或填 NULL 则表示不限制等待类型。 |
| --report_type | 否 | string | 默认为TEXT | 报告类型,目前仅支持 TEXT 类型,可不填写。 |
| --store_dir | 否 | string | 默认为命令执行的当前路径 | 存储结果的本地路径。 |
| -c | 否 | string | ~/.obdiag/config.yml |
配置文件路径。 |
| --inner_config | 否 | string | 默认为空 | obdiag 自用的配置。 |
| --config | 否 | string | 默认为空 | 需被 obdiag 诊断的集群的配置,固定样式:--config key1=value1 --config key2=value2。 |
使用示例
方式一:无配置文件使用(开箱即用)
说明
本节命令中使用的详细配置介绍可参见 obdiag 配置。
obdiag gather ash \
--config db_host=xx.xx.xx.xx \
--config db_port=xxxx \
--config tenant_sys.user=root@sys \
--config tenant_sys.password=***
输出如下:
gather_ash_report start ...
gather from_time: 2024-05-13 10:59:41, to_time: 2024-05-13 11:29:41
from_time: 2024-05-13 10:59:41, to_time: 2024-05-13 11:29:41, sql_id: None, trace_id: None, report_type: TEXT, wait_class: None, store_dir: ./
save ash report file name: ./obdiag_gather_pack_20240513112941/ash_report_20240513112941.txt
Gather ash_report results stored in this directory: ./obdiag_gather_pack_20240513112941
Trace ID: 08acff2a-10d9-11ef-9b05-02420b9e4df1
If you want to view detailed obdiag logs, please run: obdiag display-trace 08acff2a-10d9-11ef-9b05-02420b9e4df1
方式二:有配置文件使用
需要确保已经在 obdiag 配置文件 config.yml 中配置好需要收集节点的登录信息。相关的详细配置介绍,参见 obdiag 配置。
obdiag gather ash
结果解读
命令执行后在指定目录下会生成一份 ASH 报告,文件形如: ./obdiag_gather_pack_20240808105846/ash_report_20240513112941.txt