Skip to content

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

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