Install
openclaw skills install dbdoctor-toolsDBdoctor database performance diagnosis platform tools. Invoke when user needs to query database instances, slow SQL, inspection reports, performance metrics, or perform SQL audit/rewrite operations.
openclaw skills install dbdoctor-tools# 1. Get tenant and project
python scripts/get_current_user.py --extract
# 2. Get instance list
python scripts/get_instance.py --tenant [tenant] --project [project]
# 3. Execute comprehensive performance diagnosis (last 1 hour)
python scripts/performance_diagnosis.py --instance-id [instance_id] --start-time [start_ts] --end-time [end_ts]
# 1. Get tenant and project of the instance
python scripts/get_instance.py
# 2. Execute inspection
python scripts/do_inspect_instance.py --instance-id [instance_id] --tenant [tenant] --project [project]
# 3. Get inspection report
python scripts/get_recent_inspect_report.py --instance-id [instance_id] --start-time [start] --end-time [end] --tenant [tenant] --project [project]
# 1. Get slow SQL list
python scripts/get_slow_sql.py --instance-id [instance_id] --start-time [start] --end-time [end]
# 2. Audit slow SQL
python scripts/sql_audit.py --instance-id [instance_id] --database [db] --schema [schema] --sql "[sql]"
# 3. Use AI to rewrite SQL (optional)
python scripts/ai_sql_rewrite.py --instance-id [instance_id] --database [db] --schema [schema] --sql "[sql]"
This skill supports two authentication modes:
DBDOCTOR_URL, DBDOCTOR_USER, DBDOCTOR_PASSWORD.DBDOCTOR_URL, DBDOCTOR_EMAIL. When a verification code is needed, the user will be prompted interactively.If DBDOCTOR_EMAIL is configured, email mode takes precedence.
Credentials are managed by the platform and injected as environment variables at runtime. This skill does not write credentials to disk. The .token_cache file (API session token only) is the only file persisted locally and is listed in .gitignore.
Two tools perform write operations that require operator care:
All other tools are read-only queries against the DBdoctor API.
The program supports two login methods:
/nephele/login to obtain a Token./drapi/user/verificationCode, prompts the user to enter the code, AES-encrypts it, and calls /nephele/login with authType=authCode.Token is cached in .token_cache. When the token expires, the system automatically re-authenticates (password mode is silent; email mode prompts for a new verification code). No manual auth management is required.
Set the following environment variables based on your login mode:
| Variable | Description | Required |
|---|---|---|
| DBDOCTOR_URL | DBdoctor API base URL (e.g. http://host:port) | Always |
| DBDOCTOR_USER | Login username (also used as UserId) | Password mode only |
| DBDOCTOR_PASSWORD | Login password (sensitive) | Password mode only |
| DBDOCTOR_EMAIL | Login email for verification code | Email mode only |
Note: If
DBDOCTOR_EMAILis set, email verification code mode is used. Otherwise, username/password mode is used.
# CLI configuration (recommended)
clawdbot skills config dbdoctor-tools DBDOCTOR_URL "http://[host]:[port]"
clawdbot skills config dbdoctor-tools DBDOCTOR_USER "[username]"
clawdbot skills config dbdoctor-tools DBDOCTOR_PASSWORD "[password]"
# CLI configuration (recommended)
clawdbot skills config dbdoctor-tools DBDOCTOR_URL "http://[host]:[port]"
clawdbot skills config dbdoctor-tools DBDOCTOR_EMAIL "[email]"
Edit ~/.clawdbot/clawdbot.json:
{
skills: {
entries: {
"dbdoctor-tools": {
env: {
// Mode 1: Password login
DBDOCTOR_URL: "http://[host]:[port]",
DBDOCTOR_USER: "[username]",
DBDOCTOR_PASSWORD: "[password]"
// Mode 2: Email login (use this instead of USER/PASSWORD)
// DBDOCTOR_URL: "http://[host]:[port]",
// DBDOCTOR_EMAIL: "[email]"
}
}
}
}
}
# Linux / Mac - Password mode
export DBDOCTOR_URL="http://[host]:[port]"
export DBDOCTOR_USER="[username]"
export DBDOCTOR_PASSWORD="[password]"
# Linux / Mac - Email mode
export DBDOCTOR_URL="http://[host]:[port]"
export DBDOCTOR_EMAIL="[email]"
# Windows PowerShell - Password mode
$env:DBDOCTOR_URL="http://[host]:[port]"
$env:DBDOCTOR_USER="[username]"
$env:DBDOCTOR_PASSWORD="[password]"
# Windows PowerShell - Email mode
$env:DBDOCTOR_URL="http://[host]:[port]"
$env:DBDOCTOR_EMAIL="[email]"
pip install -r requirements.txt
Dependencies: requests, pycryptodome, python-dotenv
Important: When tenant and project information is needed, it must be dynamically retrieved through tools, and is prohibited from being extracted directly from user input.
Strictly prohibited from fabricating tenant and project information
Method 1: Retrieve via get_current_user (Recommended)
1. Call get_current_user --extract to get all tenants and projects
2. Select target tenant and project
3. Call get_instance --tenant xxx --project yyy
4. Select target instance and execute other operations
Method 2: Retrieve via get_instance (Recommended)
1. Call get_instance to query all instances (no parameters needed)
2. Find target instance from returned data
3. Extract tenant and project from instance data
Strictly prohibited from calling interfaces not defined in this document
get_current_user --extract
|
get_instance --tenant xxx --project yyy
|
performance_diagnosis --instance-id xxx --start-time t1 --end-time t2
|
[Based on diagnosis results]
- Many slow SQLs -> sql_audit / ai_sql_rewrite
- Resource bottleneck -> get_host_resource_info / get_basic_monitor_info
- High active sessions -> get_aas_info / get_current_process
get_instance -> do_inspect_instance -> get_recent_inspect_report
get_slow_sql / get_related_sql_info -> sql_audit -> ai_sql_rewrite (if needed)
get_current_user --extract -> manage_instance -> get_instance (confirm)
| Task Type | Required Information | Collection Strategy | Notes |
|---|---|---|---|
| Query Instance | None | Call tool directly | Get instance list and tenant/project |
| Instance Inspection | Instance ID | Check -> Ask -> Call | tenant/project via get_instance |
| Performance Diagnosis | Instance ID + Time Range | Check -> Ask -> Call | tenant/project via get_instance |
| View Data | Instance ID | Check -> Ask -> Call | tenant/project via get_instance |
For detailed processing strategies, decision trees and rules: reference/agent_guidelines.md
For complete API documentation with parameters, examples, and related pages, see: reference/api_reference.md
| Tool | Required Parameters |
|---|---|
| get_instance | None (returns all instances) |
| get_current_user | None (get current user tenant-project info) |
| get_instance_abnormal | --instance-id |
| get_database_by_instance | --instance-id |
| manage_instance | --ip, --port, --engine, --db-user, --db-password, --db-version, --tenant, --project |
| get_slow_sql | --instance-id, --start-time, --end-time |
| get_table_ddl | --instance-id, --database, --schema, --table |
| execute_sql | --instance-id, --database, --schema, --sql, --engine, --tenant, --project |
| sql_audit | --instance-id, --database, --schema, --sql |
| get_sql_audit_rules | --engine (optional), --priority (optional) |
| do_inspect_instance | --instance-id, --tenant (optional), --project (optional) |
| get_recent_inspect_report | --instance-id, --start-time, --end-time, --tenant, --project |
| get_inspect_item | None |
| get_current_process | --instance-id |
| alert_message | --status (optional), --priority (optional), --instance-ip (optional) |
| performance_diagnosis | --instance-id, --start-time, --end-time (comprehensive, recommended) |
| get_basic_monitor_info | --instance-id, --start-time, --end-time |
| get_host_resource_info | --instance-id, --start-time, --end-time |
| get_db_parameter_info | --instance-id |
| get_aas_info | --instance-id, --start-time, --end-time |
| get_related_sql_info | --instance-id, --start-time, --end-time |
| get_instance_info | --instance-id |
| get_slow_sql_by_time | --instance-id, --start-time, --end-time |
| ai_sql_rewrite | --instance-id, --database, --schema, --sql |
| get_sql_rewrite_result | --task-id |
get_instance — never fabricate or extract from user inputreference/api_reference.md - Complete Tool API Reference (parameters, examples, related pages)reference/performance_diagnosis_guide.md - Performance Diagnosis Knowledge Basereference/best_practices.md - Best Practices Guidereference/audit_and_inspection_rules.md - SQL Audit Rules and Inspection Rulesreference/troubleshooting.md - Common Issues and Solutionsreference/agent_guidelines.md - Agent Processing Strategies and Decision Guidelines