|
1 | 1 | # cloud-cli |
2 | 2 |
|
3 | | -`cloud-cli` is a command-line tool designed to simplify the management and diagnosis of server-side applications. It provides an interactive menu to access various diagnostic tools, making it easier for developers and system administrators to troubleshoot processes. |
| 3 | +`cloud-cli` is an interactive command-line tool for on-call troubleshooting of Apache Doris / SelectDB clusters. It provides a TUI menu that groups common FE/BE diagnostic workflows and writes collected artifacts into an output directory for easy archiving and sharing. |
4 | 4 |
|
5 | 5 | ## Features |
6 | 6 |
|
7 | | -The tool is organized into two main categories: |
| 7 | +The tool is organized into two categories: `FE` and `BE`. |
8 | 8 |
|
9 | | -### FE (Frontend/Java Applications) |
| 9 | +### FE |
10 | 10 |
|
11 | | -- **`jstack`**: Prints Java thread stack traces for a given Java process, helping to diagnose hangs and deadlocks. |
12 | | -- **`jmap`**: Generates heap dumps and provides memory statistics for a Java process, useful for analyzing memory leaks. |
| 11 | +- `fe-list`: List and select the FE target host (IP) for the current session based on `clusters.toml`. |
| 12 | +- `jmap` (`jmap-dump`, `jmap-histo`): Java heap dump / histogram. |
| 13 | +- `jstack`: Java thread dump. |
| 14 | +- `fe-profiler`: Generate a flame graph using Doris `bin/profile_fe.sh` (requires async-profiler). |
| 15 | +- `table-info`: Interactive database/table browser that collects and summarizes schema, indexes, partitions, and bucket details (supports exporting `.txt` reports). |
| 16 | +- `routine-load`: Routine Load helper tools: |
| 17 | + - `Get Job ID`: List and select a Routine Load job (cached locally for later analysis). |
| 18 | + - `Performance Analysis`: Analyze per-commit rows/bytes/time from FE logs. |
| 19 | + - `Traffic Monitor`: Aggregate per-minute `loadedRows` from FE logs. |
| 20 | +- `fe-audit-topsql`: Parse `fe.audit.log`, normalize SQL into templates, and aggregate by CPU/time to generate a TopSQL report. Default filter is `count > 10`; if nothing matches, it falls back to showing results without the count filter. |
13 | 21 |
|
14 | | -### BE (Backend/General Processes) |
| 22 | +### BE |
15 | 23 |
|
16 | | -- **`pstack`**: Displays the stack trace for any running process, offering insights into its execution state. |
17 | | -- **`get_be_vars`**: Retrieves and displays the environment variables of a running process. |
| 24 | +- `be-list`: List and select the BE target host (IP) for the current session based on `clusters.toml` (defaults to `127.0.0.1`). |
| 25 | +- `pstack`: Use `gdb` to dump process thread stacks (writes a `.txt` file). |
| 26 | +- `jmap` (`jmap-dump`, `jmap-histo`): Java heap dump / histogram (only meaningful for JVM processes). |
| 27 | +- `be-config`: |
| 28 | + - `get-vars` (`get-be-vars`): Query BE configuration variables via HTTP `/varz`. |
| 29 | + - `update-config` (`set-be-config`): Update configuration via HTTP `/api/update_config` (supports persist). |
| 30 | +- `pipeline-tasks`: Fetch running pipeline tasks via HTTP `/api/running_pipeline_tasks` (auto-saves when the response is large). |
| 31 | +- `memz`: |
| 32 | + - `current` (`memz`): Fetch the current Jemalloc memory view via HTTP `/memz` (saves HTML and prints a summary). |
| 33 | + - `global` (`memz-global`): Fetch the global memory view via HTTP `/memz?type=global`. |
18 | 34 |
|
19 | 35 | ## Usage |
20 | 36 |
|
21 | | -To run the application, execute the binary. An interactive menu will appear, allowing you to select the desired diagnostic tool. |
| 37 | +### Build and run |
22 | 38 |
|
23 | 39 | ```sh |
24 | | -./cloud-cli |
| 40 | +cargo build --release |
| 41 | +./target/release/cloud-cli |
25 | 42 | ``` |
26 | 43 |
|
| 44 | +### Configuration |
| 45 | + |
| 46 | +- Persistent config: `~/.config/cloud-cli/config.toml` |
| 47 | +- MySQL key file: `~/.config/cloud-cli/key` |
| 48 | +- Cluster topology cache: `~/.config/cloud-cli/clusters.toml` |
| 49 | +- First run: if an FE process is detected and MySQL credentials are missing, it will prompt you to configure and test the connection. On success, it writes `config.toml` and fetches cluster topology into `clusters.toml` (used by `fe-list`/`be-list`). |
| 50 | +- Common environment variables (override persistent config): |
| 51 | + - `JDK_PATH`: Set the JDK path (used by `jmap`/`jstack`). |
| 52 | + - `OUTPUT_DIR`: Set the output directory (default: `/tmp/doris/collection`). |
| 53 | + - `CLOUD_CLI_TIMEOUT`: External command timeout in seconds (default: `60`). |
| 54 | + - `CLOUD_CLI_NO_PROGRESS`: Disable progress animation (`1`/`true`). |
| 55 | + - `MYSQL_HOST` / `MYSQL_PORT`: Set Doris MySQL endpoint (defaults are derived from config; otherwise `127.0.0.1:9030`). |
| 56 | + - `PROFILE_SECONDS`: Override `fe-profiler` collection duration in seconds. |
| 57 | + - `CLOUD_CLI_FE_AUDIT_TOPSQL_INPUT`: Provide an explicit `fe.audit.log` path for `fe-audit-topsql` (skips interactive selection). |
| 58 | + |
| 59 | +### Output |
| 60 | + |
| 61 | +- Most tools write artifacts into the output directory (default: `/tmp/doris/collection`) and print `Output saved to: ...`. |
| 62 | +- A few tools primarily print to stdout (e.g., `get-be-vars`), but still follow consistent prompts and error messages. |
| 63 | + |
| 64 | +### Runtime dependencies |
| 65 | + |
| 66 | +The CLI invokes some system commands at runtime. Ensure these are installed and available in `PATH`: |
| 67 | + |
| 68 | +- `mysql` (for cluster info, Routine Load, Table Info, etc.) |
| 69 | +- `curl` (for BE HTTP tools) |
| 70 | +- `gdb` (for `pstack`) |
| 71 | +- `bash` |
| 72 | + |
27 | 73 | ## Releases |
28 | 74 |
|
29 | | -This project uses GitHub Actions to automatically build and release binaries for Linux (`x86_64` and `aarch64`). When a new version is tagged (e.g., `v1.0.0`), a new release is created. |
| 75 | +This project uses GitHub Actions to build and publish Linux (`x86_64` / `aarch64`) binaries. When you create a tag (e.g., `v1.0.0`), a corresponding GitHub Release is produced. |
30 | 76 |
|
31 | | -You can download the latest pre-compiled binaries from the [GitHub Releases](https://github.com/QuakeWang/cloud-cli/releases) page. |
| 77 | +You can download the latest prebuilt binaries from GitHub Releases: https://github.com/QuakeWang/cloud-cli/releases |
0 commit comments