If OceanBase Diagnostic Tool (obdiag) is independently deployed, you can use the obdiag display command to collect related information of OceanBase Database.
View supported scenarios
obdiag display scene list
Use the obdiag display scene run command
obdiag display scene run --scene={SceneName}
The following table describes the options.
| Option | Required? | Data type | Default value | Description |
|---|---|---|---|---|
| --scene | Yes | string | Empty | The name of the scenario. You can run the obd obdiag display scene list command to view the scenarios supported by the current version. |
| --env | No | string | Empty | Additional parameters required for the obdiag display command in certain scenarios. |
| -c | No | string | ~/.obdiag/config.yml |
The path of the configuration file. |
| --inner_config | No | string | Empty | The configurations of obdiag. |
| --config | No | string | Empty | The configurations of the cluster diagnosed by obdiag, in the format of --config key1=value1 --config key2=value2.
NoteFor information about the parameters supported by this option, see Configure obdiag. |
Note
The obdiag display command does not store collected information in the disk but only displays the information on the CLI.
Examples
Method 1: Use obdiag out-of-the-box without a configuration file
obdiag display scene run --scene={SceneName} \
--config db_host=xx.xx.xx.xx \
--config db_port=xxxx \
--config tenant_sys.user=root@sys \
--config tenant_sys.password=***
Method 2: Use obdiag with a configuration file
Before you use obdiag, make sure that you have configured the login information of the target nodes in the config.yml configuration file of obdiag. For more information, see Configure obdiag.
obdiag display scene run --scene={SceneName}
Tutorial for writing a task
A task is a specific scenario. obdiag runs a task based on the dedicated script file in the YAML format.
Preparations
Go to ${display.scenes_base_path} and create a sample file named test.yaml for testing OceanBase Database.
cd ~/.obdiag/display/tasks/observer
touch test.yaml
Now you are prepared.
Write a task
To write a task is to edit the test.yaml file.
# Declare the purpose of the task.
info: "for test"
Pay attention to the details when you write the task.
Task writing description
The task script is a list that declares the steps to be executed in scenario-based collection. The steps may vary based on the version.
An element of a task involves the following parameters.
| Parameter | Required? | Description | Data type |
|---|---|---|---|
| version | No | The OceanBase Database versions that the script is compatible with. An example is provided below the table. | The value is a left-open right-closed range with complete version numbers in the form of a string, such as [3.1.1,3.2.0]. A version number contains three digits for OceanBase Database V3.x or four digits for OceanBase Database V4.x. |
| steps | Yes | The steps to be executed. | The value is a list. |
Here is an example:
info: testinfo
task:
- version: "[3.1.0,3.2.4]"
steps:
{steps_object}
- version: [4.2.0.0,4.3.0.0]
steps:
{steps_object}
steps is a list of multiple execution processes.
An element of steps is a single step that involves the following parameters.
| Parameter | Required? | Description |
|---|---|---|
| type | Yes | The type of the execution step. At present, only SQL is supported. More types will be supported in later versions. |
| {sql} | Yes | The parameters for the selected type, which depend on the logic description of the execution type in the code. Description of supported execution steps will be provided in later versions of this topic. |
In the following example, step: serves only as a mark and has no actual meaning.
sql
Execute an SQL statement and obtain the corresponding value.
step:
type: sql
sql: select tenant_name from oceanbase.__all_tenant;
global: false
Note
The global field specifies whether to execute a step only on a single node or on all nodes. The value true specifies to execute the step only on the first node. The value false specifies to execute the step on each node.