Skip to content

This is the multi-page printable view of this section. .

Return to the regular view of this page.

Your first check

Build, connect, patrol and follow a canonical command.

1. Prepare and install

Use a KES V8R6 or V9 instance. Build using the Go version required by the source repository’s go.mod, then copy the static binary to the database host. Choose GOARCH=arm64 for ARM.

git clone https://github.com/Kevin-wenyu/kbdiag.git
cd kbdiag
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags "-X main.version=2.0.0" -o kbdiag ./cmd/kbdiag
scp kbdiag kingbase@db-host:~/kbdiag

On the host, use your approved OS account and chmod +x ~/kbdiag. Run ~/kbdiag --version to confirm the binary (builds without -ldflags "-X main.version=..." print dev).

2. Connect

Defaults: -h /tmp, -p 54321, -d test, -U system (Unix socket /tmp/.s.KINGBASE.54321). Precedence is explicit CLI flag > KINGBASE_* > PG* > default (KINGBASE_HOST/PGHOST, KINGBASE_PORT/PGPORT, KINGBASE_DATABASE/PGDATABASE, KINGBASE_USER/PGUSER, KINGBASE_PASSWORD/PGPASSWORD, PGSSLMODE). Use -h <hostname> for TCP connections, -W/--password for no-echo TTY password prompts, --sslmode to set SSL mode, and --help for command help. Passwords are also read from KINGBASE_PASSWORD, PGPASSWORD, or ~/.pgpass. --timeout bounds each query and --total-timeout bounds the whole command. If the server requires scram-sm3 authentication, kbdiag reports guidance to use a local Unix socket or a compatible authentication channel.

Use an approved monitoring account. sys_monitor can reveal fields hidden from ordinary users; a missing privilege is reported, not silently treated as empty. TCP cannot provide local database-host filesystem measurements.

3. Run

~/kbdiag status
~/kbdiag check --html ./patrol.html
echo $?
~/kbdiag session
~/kbdiag lock --tree
~/kbdiag sql top

The HTML report omits raw SQL and configuration credentials (passwords, connection URIs, env secrets) by default and writes atomically with 0600 permissions. Review it before sharing. See Read results for output format and exit code details.

4. Read exit codes

CodeMeaning
0OK within collected scope
1WARN: investigate the finding
2FAIL: urgent finding in visible evidence
3UNKNOWN: required evidence missing or masked
64Invalid command or flags
69Could not connect

Read $? immediately after the command. WARN/FAIL can coexist with missing coverage; inspect both. Scope and permission gaps remain meaningful even when the exit code is 1 or 2.

5. Drill down

Use lock --tree then session <pid> for blockers; session waits for wait distributions; sql top then sql show --id=<int64> for cumulative workload. object table [name], vacuum and freeze inspect the selected database; switch with -d for another database.

Read results · All 17 command cards

1 - Read the evidence

Terminal layout, verdicts, coverage markers, scope boundaries, and JSON structure.

Output layout

Every command begins with a single header line identifying the command/operation ID, verdict, target identity, and timestamp. Depending on the command, it is followed by optional [COVERAGE] (skipped/error), [REDACTED] (masked fields), findings ([FINDINGS] or inline [WARN]/[FAIL] blocks on session/lock/txn), command-specific data sections, and [NEXT].

<command>  <VERDICT>  (<version>, <role>, <user>@<host>, endpoint=<target>, <collected_at>)
[COVERAGE]
  <probe_id>: skipped|error (<reason>)
[REDACTED]
  <probe_id>.<field>: <reason>
[FINDINGS]            # session/lock/txn print [WARN]/[FAIL] directly
  <LEVEL> <finding_id>: <symptom>
    verify: <next command>
[...command sections...]
[NEXT]
  <next command or operator action>

Long context headers wrap cleanly to 80 columns. Scripts should inspect --json fields (command, verdict, context, findings, data, redacted) rather than parsing terminal wording; legacy operation IDs (such as inst.summary on server) remain stable in JSON output.

Verdict, scope and missing evidence

Always verify target identity, collection time, and coverage before interpreting rows.

  • point is an instantaneous snapshot; counter accumulates since stats reset; delta compares samples; estimate uses catalog statistics (relpages) rather than locking tables.
  • A current-database check (object, vacuum, freeze table list, lock table names) says nothing about tables in other databases.
  • redacted / [REDACTED] records privilege masking (sys_monitor, sys_read_all_settings, etc.); skipped and error mark uncollected probes; not_applicable marks role/environment inapplicability rather than failure.
  • ? never means zero, and - never proves a healthy value; a higher-severity FAIL/WARN never hides coverage gaps.

Example interpretation & safety

Reference pages show captured KES V9 terminal outputs illustrating healthy, alert, or restricted-privilege paths depending on the command. Where a card omits routine rows with ... or lowers threshold flags to capture a warning sample, the example heading states it explicitly.

JSON and follow-up actions

Run kbdiag check --json or kbdiag session <pid> --json for structured JSON containing top-level command, verdict, context, findings, data (map keyed by probe_id), and redacted. Follow-up suggestions include read-only verification commands (kbdiag ...) and, where human intervention is needed, proposed SQL or DBA actions shown strictly for review—never executed by kbdiag.

Return to quick start