当前位置: 首页 > Skill >

Alibabacloud Rds Mysql Inspection

Alibabacloud Rds Mysql Inspection

Alibabacloud Rds Mysql Inspection

阿里云RDS MySQL实例批量健康检查。支持单个、多个或全部实例全局扫描,可配置时间窗口(默认...)

0.0.1 2026.11.23 636
获取Skill文件查看使用说明
作 者:江澄 许可证: 更新时间:2026.11.23
本文目录展开

Alibaba Cloud RDS MySQL Instance Inspection Skill

This skill performs batch health inspections of Alibaba Cloud RDS MySQL instances. It supports three modes — single instance, multiple instances, and global batch — with a configurable time window (default 7 days, up to 30 days), and produces standardized HTML inspection reports.

Usage

You do not need to run any command manually. Simply describe the request in natural language.

Example Prompts

Example 1: Single instance

  • EN: Inspect RDS instance rm-bp1xxxxxx
  • ZH: 帮我巡检下 RDS 实例 rm-bp1xxxxxx

Example 2: Multiple instances with a custom time window

  • EN: Inspect rm-bp1xxx and rm-bp1yyy for the past 14 days
  • ZH: 巡检 rm-bp1xxx 和 rm-bp1yyy 这两个实例,看最近 14 天的情况

Example 3: Global inspection

  • EN: Run a health inspection on all RDS MySQL instances and produce a summary report
  • ZH: 帮我对所有 RDS MySQL 实例做一次健康巡检,输出汇总报告

Example 4: Limit by region

  • EN: Inspect all RDS MySQL instances in cn-hangzhou and cn-shanghai
  • ZH: 巡检 cn-hangzhou 和 cn-shanghai 两个 region 的所有 RDS MySQL 实例

What the AI Does Automatically

  1. Recognizes the user intent (single / multiple / global) and extracts the time-window parameters.
  2. Calls rds describe-regions to obtain the list of available regions (filters out ClosedDown).
  3. Concurrently scans every region for RDS MySQL instances (region ID is carried automatically — the user does not need to specify it).
  4. Concurrently retrieves attributes, monitoring, alerts, slow logs, and space data for each target instance.
  5. Automatically detects cluster instances and collects per-node data.
  6. Emits one HTML report per instance plus a summary HTML report, including a health-score ranking and optimization suggestions.

Prerequisites

Runtime

  • Python: 3.7+ (standard library only)
  • OS: Linux / macOS / Windows
  • Aliyun CLI: >= 3.3.3, configured with valid credentials

Installation Checks

Pre-check: Aliyun CLI >= 3.3.3 required

Run aliyun version to verify the version is >= 3.3.3. If the CLI is missing or outdated, run curl -fsSL https://aliyuncli.alicdn.com/setup.sh | bash to install or upgrade, or follow https://help.aliyun.com/zh/cli/ for installation instructions.

Pre-check: Aliyun CLI plugin update required

[MUST] Run aliyun configure set --auto-plugin-install true to enable automatic plugin installation. [MUST] Run aliyun plugin update to ensure all locally installed plugins are up to date.

aliyun version
aliyun configure set --auto-plugin-install true
aliyun plugin update

Python Dependencies

Only Python standard library modules are used (subprocess, json, argparse, concurrent.futures, datetime); pip install is not required.

[MUST] CLI User-Agent and AI-Mode Mandatory Rules

[MUST] CLI User-Agent — Every aliyun CLI invocation made by this skill must include: --user-agent AlibabaCloud-Agent-Skills/alibabacloud-rds-mysql-inspection

The call_cli() wrapper in scripts/inspect.py injects this UA automatically, so it does not need to be repeated on each command.

[MUST] Enable AI-Mode — AI-mode must be enabled before any Agent Skill execution. Run the following before invoking any CLI command:

aliyun configure ai-mode enable
aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-rds-mysql-inspection"

[MUST] Disable AI-Mode at EVERY exit point — Before delivering the final response (regardless of success, failure, exception, user cancellation, or session end), AI-mode must be disabled. AI-mode is reserved for active Agent Skill executions and must not remain enabled once the skill stops running.

aliyun configure ai-mode disable

Required RAM Permissions

This skill uses read-only RDS / CMS / DAS APIs. The full custom-policy JSON, per-action purpose table, and system-policy alternatives are declared in references/ram-policies.md. Attach that policy to the executing RAM identity before running the skill.

Authentication

Pre-check: Alibaba Cloud Credentials Required

Security Rules:

  • NEVER read, echo, or print AK/SK values
  • NEVER ask the user to input AK/SK directly in the conversation or command line
  • ONLY use aliyun configure list to check credential status
aliyun configure list

Inspect the output and confirm a valid profile exists. If no credentials are configured, guide the user to configure them outside of the conversation:

aliyun configure

CLI Argument Reference

python3 scripts/inspect.py [options]
Argument Short Type Description Default
--instance-ids -i string Instance ID (repeatable, or comma-separated in a single value) none
--all — flag Globally inspect every RDS MySQL instance off
--days -d int Time-window length in days (1-30) 7
--start-time — YYYY-MM-DD Start date (mutually exclusive with --days) none
--end-time — YYYY-MM-DD End date (must be supplied together with --start-time) none
--output -o path Output directory ./rds-inspection-reports/<ts>/
--profile -p string Aliyun CLI profile name default profile
--regions — string Limit the scan to specific regions (comma-separated) all
--concurrency -c int Per-instance inspection concurrency 3
--region-concurrency — int Region scan concurrency 3
--skip-space — flag Skip the DAS space analysis (saves 30-150 s per instance) off

Validation rules (enforced automatically by the script):

  • Exactly one of -i or --all is required.
  • --days must be between 1 and 30; values outside this range raise an error.
  • --start-time and --end-time must be supplied together, with a span of <= 30 days.

Core Workflow

Phase 1: Fetch the Available Region List

aliyun rds describe-regions --region cn-hangzhou --user-agent AlibabaCloud-Agent-Skills/alibabacloud-rds-mysql-inspection

Extract RegionId from the returned Regions.RDSRegion[] and drop any region whose Status contains closed.

Phase 2: Concurrently Scan RDS MySQL Instances Across Regions

For each region, call:

aliyun rds describe-db-instances --region <RegionId> 
  --engine MySQL --page-size 100 --page-number <N> 
  --user-agent AlibabaCloud-Agent-Skills/alibabacloud-rds-mysql-inspection

Paginate based on TotalRecordCount until all records are retrieved. Merge into a complete [{instanceId, regionId, ...}] list.

Phase 3: Filter Target Instances

  • --all: every instance.
  • -i id1,id2: filter from the full list (the region ID for each instance is carried automatically; the user does not need to specify it).

Unmatched instance IDs produce a warning but do not abort the overall workflow.

Phase 4: Instance Attribute Query (default concurrency 3)

aliyun rds describe-db-instance-attribute --region <RegionId> 
  --db-instance-id <InstanceId> --user-agent AlibabaCloud-Agent-Skills/alibabacloud-rds-mysql-inspection

Extract the key fields: Category (determines whether the instance is a cluster), DBClusterNodes (cluster node list), MaxConnections, MaxIOPS, MaxIOMBPS, CurrentKernelVersion, LatestKernelVersion, ExpireTime, etc.

Phase 5: Per-Instance Inspection (default concurrency 3)

Within each instance, the following collection steps run sequentially.

5.1 CMS Metric Collection (cms describe-metric-list)

Five core metrics. The MetricName and Dimensions depend on whether the instance is a cluster.

Cluster instances (Category=cluster, queried per node):

MetricName Meaning
Cluster_CpuUsage CPU utilization
Cluster_MemoryUsage Memory utilization
Cluster_DiskUsage Disk utilization
Cluster_IOPSUsage IOPS utilization
Cluster_ConnectionUsage Connection utilization

Dimensions: [{"instanceId":"<DBInstanceId>","nodeId":"<NodeId>"}]

Non-cluster instances:

MetricName Meaning
CpuUsage / MemoryUsage / DiskUsage / IOPSUsage / ConnectionUsage Same as above

Dimensions: [{"instanceId":"<DBInstanceId>"}]

Invocation template:

aliyun cms describe-metric-list 
  --namespace acs_rds_dashboard 
  --metric-name <MetricName> 
  --period 60 
  --start-time <StartMillis> --end-time <EndMillis> 
  --dimensions '<JSON>' 
  --length 2000 
  --user-agent AlibabaCloud-Agent-Skills/alibabacloud-rds-mysql-inspection

Paginate via NextToken until all data points are retrieved.

5.2 CMS Alert History (cms describe-alert-log-list)

aliyun cms describe-alert-log-list 
  --namespace acs_rds_dashboard --product rds 
  --search-key <DBInstanceId> 
  --start-time <ms> --end-time <ms> 
  --page-size 100 --page-number <N>

Page through all results. Sort by alert severity in descending order: CRITICAL / P0 / P1 > WARN / P2 > INFO / P3 / P4.

5.3 DAS Slow Log Statistics (das describe-slow-log-statistic)

aliyun das describe-slow-log-statistic 
  --instance-id <DBInstanceId> 
  --start <ms> --end <ms> 
  --order-by <Count|QueryTime> 
  [--node-id <NodeId>] 
  --endpoint das.cn-shanghai.aliyuncs.com

Notes:

  • The DAS endpoint is fixed at das.cn-shanghai.aliyuncs.com (DAS is centrally deployed).
  • Cluster instances must pass --node-id (use the Master node).
  • Run the query twice — once ordered by Count and once by QueryTime.

5.4 DAS Space Analysis — Top 20

# Trigger the task
aliyun das create-storage-analysis-task 
  --instance-id <DBInstanceId> 
  --endpoint das.cn-shanghai.aliyuncs.com

# Poll for results
aliyun das get-storage-analysis-result 
  --instance-id <DBInstanceId> --task-id <TaskId> 
  --endpoint das.cn-shanghai.aliyuncs.com

Poll every 5 seconds, with a 180-second cap. Take the top 20 tables from StorageAnalysisResult.TableStats.

Phase 6: Health Score Calculation

Each instance is scored 0-100. Deductions:

  • CPU / memory / IOPS / connection peak > 80%: -10; > 60%: -5
  • Disk > 85%: -15; > 70%: -5
  • Total slow log entries > 1000: -8; > 100: -3
  • Critical / severe alerts: -10
  • Kernel version not on the latest release: -3
  • Expiring within 30 days: -5
  • Instance is in Lock state: -8

Phase 7: Single-Instance HTML Rendering (5 Sections)

Each instance produces instances/<DBInstanceId>.html containing the following sections:

  1. Instance basics — DBInstanceId / Engine + Version / Category (with a (cluster) tag) / Class / Storage / MaxConnections / MaxIOPS / MaxIOMBPS / primary and secondary zones / VPC + VSwitch / status / pay type / Lock / maintenance window / creation + expiration / current + latest kernel / cluster node list (for clusters).
  2. Resource utilization (past N days) — A table with average / peak / status color per metric, plus five ECharts line charts (linked via dataZoom); one line per node for clusters.
  3. Top 20 space-consuming tables — Sorted from DAS TableStats. Columns: database / table / total space / data / index / fragmentation / row count.
  4. Slow log statistics (past N days) — Two tables: top by Count and top by QueryTime.
  5. Alert history (past N days) — Table sorted by severity, capped at 200 rows.

Phase 8: Summary HTML Rendering (8 Sections)

Outputs summary.html, with anchor navigation plus the following eight sections:

  1. Inspection overview — KPI cards (total / region count / cluster count / global health score / health distribution / alerting instance count) plus four pie / bar charts (category / status / health / per region).
  2. Health score ranking — Top 20 least-healthy instances, each row linking to the corresponding single-instance report.
  3. Alerting instance statistics — KPI cards + a severity-distribution bar chart + the top 20 instances by alert count.
  4. Resource utilization Top lists — Five top-20 tables (CPU / memory / disk / IOPS / connections), sorted by peak value.
  5. Slow log Top lists — Top instances by slow log count, by total execution time, and by single-statement maximum execution time (aggregated across instances).
  6. Space analysis — Top instances by used space, top 20 single tables (aggregated across instances), and tables with the highest fragmentation rate.
  7. Version and expiration — Instances with kernel upgrades available, expiring within 30 days, and expiring within 90 days.
  8. Inspection conclusion — KPI cards (global health score + instance counts in the healthy / needs-attention / critical categories) plus an aggregated issue list (grouped by issue type: high CPU / high memory / tight space / many slow logs / many alerts / outdated kernel / approaching expiration — each row lists the affected instance IDs).

Report Output Structure

./rds-inspection-reports/<timestamp>/
├── summary.html                  # Aggregated inspection report (8 sections)
└── instances/
    ├── rm-bp1xxx.html            # Per-instance report (5 sections)
    ├── rm-bp1yyy.html
    └── ...

In the summary report, every instance ID is a hyperlink that opens the corresponding per-instance report in a new tab.

Status Thresholds

Metric Normal Warning Critical
CPU utilization < 60% 60-80% > 80%
Memory utilization < 60% 60-80% > 80%
Disk utilization < 70% 70-85% > 85%
IOPS utilization < 60% 60-80% > 80%
Connection utilization < 60% 60-80% > 80%
Overall health score >= 80 60-79 < 60

Cluster vs Non-Cluster Handling

Dimension Non-cluster instance Cluster instance (Category=cluster)
CMS MetricName No prefix (CpuUsage, etc.) Prefixed with Cluster_
CMS Dimensions {"instanceId":"<id>"} {"instanceId":"<id>","nodeId":"<nid>"}, queried per node
DAS slow log --instance-id only Must also pass --node-id (use the Master node)
HTML metric charts Single line One line per node
Cluster-level aggregation N/A CPU / memory peak = max of all node peaks

The cluster node list is obtained from the DBClusterNodes field returned by rds describe-db-instance-attribute.

Performance Estimates

Scenario Estimated Duration
Single instance (with space analysis) 60-200 seconds
Single instance (--skip-space) 10-30 seconds
10 instances at concurrency 3 5-15 minutes
50 instances with --all 30-90 minutes

Tips for faster runs:

  • For large batches, use --skip-space; DAS space analysis costs 30-150 seconds per instance.
  • When the target instances' regions are known, use --regions cn-hangzhou,... to skip other regions.
  • Increase -c for higher concurrency (be aware that the CMS API has a default 20 QPS limit; <= 5 is recommended).

Safety Rules

This is a read-only inspection skill.

  • Mutating operations (DDL / DML, instance configuration changes) are strictly forbidden.
  • Only inspection results and optimization suggestions are produced.
  • The single non-read CLI call used by this skill is das create-storage-analysis-task, which schedules a side analysis task and does not modify any instance data; all other invocations are pure read operations.
  • Any mutating operation must be confirmed and executed manually by the user outside of the conversation.

References

  • scripts/inspect.py — Main inspection script (CLI + collection + rendering).
  • references/ram-policies.md — Full RAM permission reference (custom policy JSON + action purposes).
  • Alibaba Cloud RDS API: https://help.aliyun.com/zh/rds/developer-reference/
  • Alibaba Cloud CMS API: https://help.aliyun.com/zh/cms/cloudmonitor-1-0/developer-reference/
  • Alibaba Cloud DAS API: https://help.aliyun.com/zh/das/developer-reference/

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,018
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,013
Skill 文件
  • SKILL.md
    • Alibaba Cloud RDS MySQL Instance Inspection Skill
    • Usage
      • Example Prompts
      • What the AI Does Automatically
    • Prerequisites
      • Runtime
      • Installation Checks
      • Python Dependencies
    • [MUST] CLI User-Agent and AI-Mode Mandatory Rules
    • Required RAM Permissions
    • Authentication
    • CLI Argument Reference
    • Core Workflow
      • Phase 1: Fetch the Available Region List
      • Phase 2: Concurrently Scan RDS MySQL Instances Across Regions
      • Phase 3: Filter Target Instances
      • Phase 4: Instance Attribute Query (default concurrency 3)
      • Phase 5: Per-Instance Inspection (default concurrency 3)
        • 5.1 CMS Metric Collection (cms describe-metric-list)
        • 5.2 CMS Alert History (cms describe-alert-log-list)
        • 5.3 DAS Slow Log Statistics (das describe-slow-log-statistic)
        • 5.4 DAS Space Analysis — Top 20
      • Phase 6: Health Score Calculation
      • Phase 7: Single-Instance HTML Rendering (5 Sections)
      • Phase 8: Summary HTML Rendering (8 Sections)
    • Report Output Structure
    • Status Thresholds
    • Cluster vs Non-Cluster Handling
    • Performance Estimates
    • Safety Rules
    • References
  • 项目或源文件

相关 Skill

更多
Volcengine RDS Mysql Volcengine RDS Mysql 使用火山引擎 RDS MySQL MCP Server,帮助用户完成 RDS MySQL 相关的实例管理、数据库操作、账号管理和运维任务,可直接调用 uv run ./scripts/call_rds_mysql.py 脚本获取实时结果。
Aliyun Adb Mysql Aliyun Adb Mysql 用于通过 OpenAPI/SDK 管理阿里云 AnalyticDB for MySQL (ADB),包括资源生命周期及配置操作。
MYSQL QUERY MYSQL QUERY 自动管理SSH隧道,查询项目数据库。适用于在已配置的数据库上执行SQL查询,尤其是需要通过SSH访问的数据库。
MySQL to PostgreSQL Migration MySQL to PostgreSQL Migration 在将项目数据库层从MySQL迁移到PostgreSQL时使用此技能。覆盖SQL方言转换(MyBatis XML/原始SQL)和ORM配置等...
在使用 Skeema 进行危险的数据库部署之前,将 MySQL 架构变更作为文件系统管理的 SQL 进行差异对比和审查 在使用 Skeema 进行危险的数据库部署之前,将 MySQL 架构变更作为文件系统管理的 SQL 进行差异对比和审查 将实时MySQL模式拉取到文件中,检查差异,并使用可重复的工作流程推送已审核的更改。