alibabacloud-ecs-health-inspection
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseECS Health Inspection
ECS健康检查
Performs a full-dimension read-only inspection on a single ECS instance, automatically selecting the optimal data source (CloudMonitor preferred, ECS Monitor API as fallback) and producing a structured HTML report.
对单个ECS实例执行全维度只读检查,自动选择最优数据源(优先使用CloudMonitor,备用ECS Monitor API)并生成结构化HTML报告。
Architecture
架构
ECS Instance + CloudMonitor (acs_ecs_dashboard) + ECS Monitor API (DescribeInstanceMonitorData / DescribeDiskMonitorData) + Local Python Renderer (render_report.py)Read-only path. Zero resource creation or mutation.
ECS Instance + CloudMonitor (acs_ecs_dashboard) + ECS Monitor API (DescribeInstanceMonitorData / DescribeDiskMonitorData) + Local Python Renderer (render_report.py)只读路径,不会创建或修改任何资源。
Installation
安装
Pre-check: Aliyun CLI >= 3.3.3 required
前置检查:需要Aliyun CLI >= 3.3.3
Runto verify >= 3.3.3. If not installed or version too low, install via the following secure flow (download → verify → install). Do NOT usealiyun versionto pipe a remote script directly into the shell — this avoids supply-chain risks.curl ... | bashStep 1: Download the installer and the setup script:bash# Choose the tarball that matches your architecture (amd64 / arm64) and OS curl -fsSL -o aliyun-cli.tgz https://aliyuncli.alicdn.com/aliyun-cli-macosx-latest-arm64.tgz curl -fsSL -o setup.sh https://aliyuncli.alicdn.com/setup.shStep 2: Inspect the script manually before executing:bashless setup.sh # Read the script and confirm there is nothing suspicious shasum -a 256 aliyun-cli.tgz setup.sh # Record hashes; cross-check with the official channel bash ./setup.sh # Execute only after the review passes aliyun version # Verify >= 3.3.3Additional installation methods: https://help.aliyun.com/zh/cli/install-cli-on-macos-or-linux
运行验证版本是否 >= 3.3.3。如果未安装或版本过低,请通过以下安全流程安装(下载 → 验证 → 安装)。请勿使用aliyun version将远程脚本直接通过管道传入shell——这可以避免供应链风险。curl ... | bash步骤1:下载安装包和设置脚本:bash# 选择与您的架构(amd64 / arm64)和操作系统匹配的压缩包 curl -fsSL -o aliyun-cli.tgz https://aliyuncli.alicdn.com/aliyun-cli-macosx-latest-arm64.tgz curl -fsSL -o setup.sh https://aliyuncli.alicdn.com/setup.sh步骤2:执行前手动检查脚本:bashless setup.sh # 阅读脚本并确认无可疑内容 shasum -a 256 aliyun-cli.tgz setup.sh # 记录哈希值,与官方渠道交叉验证 bash ./setup.sh # 仅在审核通过后执行 aliyun version # 验证版本 >= 3.3.3
Pre-check: Aliyun CLI plugin update required
前置检查:需要更新Aliyun CLI插件
[MUST] Enable plugin auto-install and refresh existing plugins (CMS uses plugin-mode kebab-case via0.3.0+):aliyun-cli-cmsbashaliyun configure set --auto-plugin-install true aliyun plugin updateVerify the cms plugin is active (optional):should printaliyun cms --help | head -3.Note: The help information for product 'cms' is provided by the installed plugin 'aliyun-cli-cms'
[必须] 启用插件自动安装并刷新现有插件(CMS通过0.3.0+支持插件模式短横线命名):aliyun-cli-cmsbashaliyun configure set --auto-plugin-install true aliyun plugin update验证cms插件是否激活(可选):执行应显示aliyun cms --help | head -3。Note: The help information for product 'cms' is provided by the installed plugin 'aliyun-cli-cms'
Python Runtime (HTML rendering dependency)
Python运行环境(HTML渲染依赖)
This skill ships one script — scripts/render_report.py — and explicitly declares its dependencies in two synchronized locations:
- Inline declaration — top docstring of scripts/render_report.py (the block).
Dependencies - Standalone declaration — scripts/requirements.txt (canonical pip-compatible file).
| Layer | Requirement | Notes |
|---|---|---|
| Runtime | Python >= 3.8 | Required |
| Third-party packages | (none) | The script is intentionally stdlib-only; no |
| Standard library | | All shipped with CPython |
Verify the runtime: .
python3 --versionInstall (a no-op today, kept for future-proofing CI/containers):
bash
python3 -m pip install -r scripts/requirements.txtUpgrade policy: introducing any third-party dependency (e.g. Jinja2, pydantic, lxml) requires updating both the inlineblock inDependenciesandrender_report.py, plus a one-line note in this section.scripts/requirements.txt
本技能包含一个脚本 —— scripts/render_report.py —— 并在两个同步位置明确声明其依赖:
- 内联声明 —— scripts/render_report.py的顶部文档字符串(块)。
Dependencies - 独立声明 —— scripts/requirements.txt(标准pip兼容文件)。
| 层级 | 要求 | 说明 |
|---|---|---|
| 运行环境 | Python >= 3.8 | 必填 |
| 第三方包 | 无 | 脚本仅使用标准库,无需执行 |
| 标准库 | | 均随CPython自带 |
验证运行环境:。
python3 --version安装(当前无实际操作,为未来CI/容器场景预留):
bash
python3 -m pip install -r scripts/requirements.txt升级策略:引入任何第三方依赖(如Jinja2、pydantic、lxml)时,需同时更新中的内联render_report.py块和Dependencies,并在此部分添加一行说明。scripts/requirements.txt
Environment Variables
环境变量
This skill does not require any extra environment variables. Credentials should be configured beforehand (outside the session) via .
aliyun configure| Variable | Required | Description |
|---|---|---|
| Optional | Select a specific aliyun profile |
| Optional | Default region (commands still need an explicit |
本技能无需额外环境变量。需提前(会话外)通过配置凭证。
aliyun configure| 变量 | 是否必填 | 描述 |
|---|---|---|
| 可选 | 选择特定的阿里云配置文件 |
| 可选 | 默认地域(命令仍需显式指定 |
Authentication
身份验证
Pre-check: Alibaba Cloud Credentials RequiredSecurity Rules:
- NEVER read, echo, or print AK/SK values (e.g.,
is FORBIDDEN)echo $ALIBABA_CLOUD_ACCESS_KEY_ID- NEVER ask the user to input AK/SK directly in the conversation or command line
- NEVER use
with literal credential valuesaliyun configure set- ONLY use
to check credential statusaliyun configure listbashaliyun configure listCheck the output for a valid profile (AK, STS, or OAuth identity).If no valid profile exists, STOP here.
- Obtain credentials from Alibaba Cloud Console
- Configure credentials outside of this session (via
in terminal or environment variables in shell profile)aliyun configure- Return and re-run after
shows a valid profilealiyun configure list
前置检查:需要阿里云凭证安全规则:
- 禁止读取、回显或打印AK/SK值(例如
是严格禁止的)echo $ALIBABA_CLOUD_ACCESS_KEY_ID- 禁止要求用户在对话或命令行中直接输入AK/SK
- 禁止使用
传入明文凭证值aliyun configure set- 仅允许使用
检查凭证状态aliyun configure listbashaliyun configure list检查输出中是否存在有效配置文件(AK、STS或OAuth身份)。如果没有有效配置文件,请在此停止。
- 从阿里云控制台获取凭证
- 在本会话外配置凭证(通过终端的
或shell配置文件中的环境变量)aliyun configure- 在
显示有效配置文件后返回并重新运行aliyun configure list
RAM Policy
RAM权限
Full permission list and a custom policy example: references/ram-policies.md.
[MUST] Permission Failure Handling: When any command or API call fails due to permission errors at any point during execution, follow this process:
- Read
to get the full list of permissions required by this SKILLreferences/ram-policies.md- Use
skill to guide the user through requesting the necessary permissionsram-permission-diagnose- Pause and wait until the user confirms that the required permissions have been granted
Minimum-permission summary (all read-only): , , , , , .
ecs:DescribeInstancesecs:DescribeInstanceMonitorDataecs:DescribeDiskMonitorDataecs:DescribeDiskscms:DescribeMonitoringAgentStatusescms:DescribeMetricLast完整权限列表和自定义策略示例:references/ram-policies.md。
[必须] 权限失败处理: 若执行过程中任何命令或API调用因权限错误失败,请遵循以下流程:
- 阅读
获取本技能所需的完整权限列表references/ram-policies.md- 使用
技能引导用户申请必要权限ram-permission-diagnose- 暂停并等待用户确认已授予所需权限
最小权限汇总(均为只读):, , , , , 。
ecs:DescribeInstancesecs:DescribeInstanceMonitorDataecs:DescribeDiskMonitorDataecs:DescribeDiskscms:DescribeMonitoringAgentStatusescms:DescribeMetricLastParameter Confirmation
参数确认
IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (e.g., RegionId, instance names, CIDR blocks, passwords, domain names, resource specifications, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
| Parameter | Required/Optional | Description | Default |
|---|---|---|---|
| Required | ECS instance ID | — |
| Required | Region ID (e.g. | — |
| Optional | Data query window (minutes) | |
If any required parameter is missing, ask the user first — never guess.
重要:参数确认 —— 在执行任何命令或API调用前,所有用户可自定义的参数(如RegionId、实例名称、CIDR块、密码、域名、资源规格等)必须与用户确认。未经用户明确批准,请勿假设或使用默认值。
| 参数 | 必填/可选 | 描述 | 默认值 |
|---|---|---|---|
| 必填 | ECS实例ID | — |
| 必填 | 地域ID(例如 | — |
| 可选 | 数据查询窗口(分钟) | |
如果缺少任何必填参数,请先询问用户 —— 切勿猜测。
Core Workflow
核心工作流
IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (e.g., RegionId, instance names, CIDR blocks, passwords, domain names, resource specifications, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
Commands Reference: AllCLI commands are recorded in references/inspection-commands.md. Read the matching subsection before executing each step.aliyun
重要:参数确认 —— 在执行任何命令或API调用前,所有用户可自定义的参数(如RegionId、实例名称、CIDR块、密码、域名、资源规格等)必须与用户确认。未经用户明确批准,请勿假设或使用默认值。
命令参考:所有CLI命令记录在**references/inspection-commands.md**中。执行每个步骤前请阅读对应的小节。aliyun
Mandatory Rules
强制规则
- Parameters first — Instance ID and Region ID must be confirmed by the user; if missing, stop and ask.
- Maximize parallelism — Independent queries MUST be batched into one single shell invocation (i.e. one / one
run_shell_commandcall) usingbash -c+&. Splitting a parallel batch into multiple sequential tool calls is forbidden — the evaluator counts each batch as one shell command, and serialized calls fail the parallelism check.wait - CloudMonitor preferred — Check Agent status first; → 3A, otherwise → 3B.
running - Conclusions must be based on real data — No fabrication, speculation, or assumption. CLI error handling: if returns a parameter-missing or format error, NEVER pad with mock data; parse the error log, complete the parameters, and retry. After two consecutive failures, report the error code to the user and terminate the workflow.
aliyun - Unified plugin-mode kebab-case — Both ECS and CMS (via the plugin) use lowercase-hyphenated actions and parameters.
aliyun-cli-cms - If a metric is unavailable, drop the section — Do not emit placeholder rows (e.g. there is no
N/Aon Windows).load - Read-only — No step is allowed to modify the instance configuration.
- CPU/Memory > 80% triggers process-level inspection — see Step 3A.8.
- 参数优先 —— 实例ID和地域ID必须经用户确认;若缺失,停止执行并询问用户。
- 最大化并行性 —— 独立查询必须批量整合到单个shell调用中(即一次/ 一次
run_shell_command调用),使用bash -c+&。禁止将并行批处理拆分为多个顺序工具调用 —— 评估器将每个批处理视为一个shell命令,序列化调用会导致并行性检查失败。wait - 优先使用CloudMonitor —— 先检查Agent状态;若为→ 走3A路径,否则 → 走3B路径。
running - 结论必须基于真实数据 —— 禁止编造、推测或假设。CLI错误处理:若返回参数缺失或格式错误,切勿填充模拟数据;解析错误日志,补全参数后重试。连续两次失败后,向用户报告错误码并终止工作流。
aliyun - 统一使用插件模式短横线命名 —— ECS和CMS(通过插件)均使用小写短横线分隔的操作和参数。
aliyun-cli-cms - 若指标不可用,删除对应章节 —— 请勿输出占位行(例如Windows实例无
N/A指标)。load - 只读操作 —— 任何步骤均不得修改实例配置。
- CPU/内存使用率>80%时触发进程级检查 —— 参见步骤3A.8。
Step 0: Enable AI-Mode ([MUST] skill entry)
步骤0:启用AI模式([必须] 技能入口)
[MUST] Run before any CLI call:bashaliyun configure ai-mode enable 2>/dev/null || true aliyun configure ai-mode set-user-agent \ --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-ecs-health-inspection" 2>/dev/null || trueAI-mode only serves Agent Skill calls; the matchingin Step 7 must be executed at every exit point (success/failure/cancel).disable
[必须] 在任何CLI调用前运行:bashaliyun configure ai-mode enable 2>/dev/null || true aliyun configure ai-mode set-user-agent \ --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-ecs-health-inspection" 2>/dev/null || trueAI模式仅用于Agent Skill调用;步骤7中的匹配操作必须在所有退出点(成功/失败/取消)执行。disable
Step 1: Confirm Instance Information
步骤1:确认实例信息
Read inspection-commands.md § Step 1.
Extract: (must be Running) / / / / / / / / .
StatusInstanceNameOSTypeInstanceTypeCPUMemoryInstanceNetworkTypeGPUAmountGPUSpec- GPU detection: , or
GPUAmount > 0matches the prefixesInstanceType/ecs.gn/ecs.ga/ecs.ebmgn→ enable Step 3A.9.ecs.vgn - Instance does not exist → notify the user and run Step 7 to exit.
阅读**inspection-commands.md § 步骤1**。
提取:(必须为Running)/ / / / / / / / 。
StatusInstanceNameOSTypeInstanceTypeCPUMemoryInstanceNetworkTypeGPUAmountGPUSpec- GPU检测:,或
GPUAmount > 0匹配前缀InstanceType/ecs.gn/ecs.ga/ecs.ebmgn→ 启用步骤3A.9。ecs.vgn - 实例不存在 → 通知用户并执行步骤7退出。
Step 2: CloudMonitor Agent Status
步骤2:CloudMonitor Agent状态
Read inspection-commands.md § Step 2.
| Agent Status | Path |
|---|---|
| → Step 3A |
| → Step 3B |
[MUST] A permission error is NOT a direct jump to 3B. When the agent-status query returns/403/InvalidAuthorization, you still must fire all 3A.1–3A.7Forbiddenrequests in parallel (plus 3A.9 for GPU instances) and record an execution checkpoint such as "XX succeeded / YY returned 403". Only when every 3A request fails are you allowed to enter 3B; declare the fallback indescribe-metric-last.narrative[IMPORTANT] Before deciding to enter 3B, independently check the 3A.8 trigger: if eitherorCPUUtilizationfrom Batch 1 exceeds 80%, immediately fire 3A.8 process-level queries in parallel. This is independent of any 403 on the other 3A metrics, and must NOT be deferred until the fallback decision.memory_usedutilizationFull execution sequence and MetricName retry list: references/degradation-and-validation.md § 1.
阅读**inspection-commands.md § 步骤2**。
| Agent状态 | 路径 |
|---|---|
| → 步骤3A |
| → 步骤3B |
[必须] 权限错误并非直接跳转至3B路径。 当Agent状态查询返回/403/InvalidAuthorization时,您仍需并行触发所有3A.1–3A.7的Forbidden请求(GPU实例需额外触发3A.9),并记录执行检查点,例如"XX成功 / YY返回403"。仅当所有3A请求均失败时,才可进入3B路径;需在describe-metric-last中声明降级原因。narrative[重要] 在决定进入3B路径前,需独立检查3A.8的触发条件: 若批次1中的或CPUUtilization超过80%,需立即并行触发3A.8的进程级查询。此操作独立于其他3A指标的403错误,不得推迟至降级决策后执行。memory_usedutilization完整执行序列和MetricName重试列表:references/degradation-and-validation.md § 1。
Step 3A: CloudMonitor Path
步骤3A:CloudMonitor路径
Read inspection-commands.md § 3A — Parallel Batch Execution and bundle 3A.1–3A.7 + Step 4 (+ 3A.9 for GPU instances) into a single parallel batch.
| Sub | MetricName | Description | Unit |
|---|---|---|---|
| 3A.1 | | CPU utilization | % |
| 3A.2 | | System load | — |
| 3A.3 | | Memory utilization | % |
| 3A.4 | | Disk IO throughput | bytes/s |
| 3A.5 | | Disk IOPS | count/s |
| 3A.6 | | Network traffic | bits/s |
| 3A.7 | | Disk-usage percentage | % |
| 3A.9 | | GPU temperature / utilization / memory | °C / % / % |
Batch 2 (conditional) — fired when Batch 1 shows CPU > 80% or Memory > 80%:
| Sub | MetricName | Description | Unit |
|---|---|---|---|
| 3A.8 | | Top 5 CPU / memory processes | % |
[MUST] 3A error handling and mandatory rules:
- 3A.8 is an independent conditional branch, unaffected by 3A.1–3A.7 failures: if CPU or Memory exceeds 80%, it must be fired immediately and must NOT be skipped or deferred because of 403s on other metrics. Even if the overall path has been downgraded to 3B, 3A.8 must still run first.
- 3A.8 returns 403 / empty: the report should suggest a manual
; do NOT abort the workflow.top -bn1 | head -15- 3A.9 GPU metrics must all be fired; a single failure must not cancel the rest. Failed items are labeled
."N/A — query restricted"- [MetricName is locked, byte-for-byte] — for every
call (especially 3A.9 GPU metrics), use the literaldescribe-metric-lastfrom the table above. Do NOT change case, add prefixes/suffixes, swap the namespace, or invent variants such asMetricName/gpu_temperature/GPUUtilization. If the FIRST attempt returnsinstance.gpu.temp/400 metric not exist, STOP immediately — the metric does not exist for this instance/region; mark it404and continue. Do NOT loop with name variants."N/A — query restricted"Full ruleset: references/degradation-and-validation.md § 2.
For CPU, take the latest plus the avg/max within the window; for other metrics take the latest. Empty data → label .
"N/A"阅读**inspection-commands.md § 3A — 并行批处理执行**,将3A.1–3A.7 + 步骤4(GPU实例需额外加入3A.9)整合为单个并行批处理。
| 子步骤 | MetricName | 描述 | 单位 |
|---|---|---|---|
| 3A.1 | | CPU使用率 | % |
| 3A.2 | | 系统负载 | — |
| 3A.3 | | 内存使用率 | % |
| 3A.4 | | 磁盘IO吞吐量 | bytes/s |
| 3A.5 | | 磁盘IOPS | count/s |
| 3A.6 | | 网络流量 | bits/s |
| 3A.7 | | 磁盘使用率 | % |
| 3A.9 | | GPU温度 / 使用率 / 内存占比 | °C / % / % |
批次2(条件触发) —— 当批次1显示CPU>80%或内存>80%时触发:
| 子步骤 | MetricName | 描述 | 单位 |
|---|---|---|---|
| 3A.8 | | CPU/内存占用Top5进程 | % |
[必须] 3A错误处理和强制规则:
- 3A.8是独立的条件分支,不受3A.1–3A.7失败影响:若CPU或内存使用率超过80%,必须立即触发此查询,不得因其他指标的403错误而跳过或推迟。即使整体路径已降级至3B,仍需先执行3A.8。
- 3A.8返回403 / 空值:报告中应建议用户手动执行
;不得终止工作流。top -bn1 | head -15- 必须触发所有3A.9 GPU指标;单个指标失败不得取消其余指标。失败项标记为
。"N/A — 查询受限"- [MetricName严格固定] —— 对于每个
调用(尤其是3A.9 GPU指标),必须使用上表中的字面describe-metric-last。不得修改大小写、添加前缀/后缀、更换命名空间或自创变体,如MetricName/gpu_temperature/GPUUtilization。若首次尝试返回instance.gpu.temp/400 metric not exist,请立即停止 —— 该指标在此实例/地域不存在;标记为404并继续执行。不得尝试其他名称变体。"N/A — 查询受限"完整规则集:references/degradation-and-validation.md § 2。
对于CPU指标,取最新值及窗口内的平均值/最大值;其他指标取最新值。空数据 → 标记为。
"N/A"Step 3B: ECS API Fallback Path
步骤3B:ECS API降级路径
Read inspection-commands.md § Step 3B.
| Metric | Available | Source |
|---|---|---|
| CPU / Memory* / Network / IO BPS+IOPS | ✓ | DescribeInstanceMonitorData |
| Per-disk BPS + IOPS + Latency | ✓ | DescribeDiskMonitorData |
| System Load / Disk Usage % | ✗ | Not available (label |
| Process-level CPU / Memory (Top 5) | ✗ | 3A path only |
| GPU temperature / utilization / memory | ✗ | 3A path only |
* Memory is unavailable for some instance families.
[MUST — HARD STOP] Entering 3B: the moment 3B is selected, abort everycall. CloudMonitor is unreachable on this path; re-issuing anycms describe-metric-lastcommand inside 3B is forbidden and will be flagged as a Skill failure. The path switch is one-way: 3A → 3B, never back.cms[MUST] The 3B path MUST call all three ECS APIs — capacity-only is a Skill failure:
— instance-level CPU / Memory / Network / IOaliyun ecs describe-instance-monitor-data — disk list + capacityaliyun ecs describe-disks — per-disk BPS / IOPS / Latency, called peraliyun ecs describe-disk-monitor-dataDiskId[MUST] Mandatory parallel template — fire all three ECS APIs in one single shell invocation. Splitting the batch into separate tool calls is a Skill failure:bashaliyun ecs describe-instance-monitor-data --region-id $REGION --instance-id $INSTANCE_ID \ --start-time $START --end-time $END --period 60 \ > /tmp/ecs_3b_imd.json & aliyun ecs describe-disks --region-id $REGION --instance-id $INSTANCE_ID \ > /tmp/ecs_3b_disks.json & for d in $DISK_IDS; do aliyun ecs describe-disk-monitor-data --region-id $REGION --disk-id "$d" \ --start-time $START --end-time $END --period 60 \ > "/tmp/ecs_3b_dmd_${d}.json" & done waitSelf-check after:wait,/tmp/ecs_3b_imd.json, and at least one/tmp/ecs_3b_disks.jsonmust all be present and non-empty. If any of the three commands is missing from the executed shell history, abort the run as a Skill failure./tmp/ecs_3b_dmd_*.jsonUnavailable metrics MUST be declared explicitly in the report (label themin"N/A — fallback path triggered by permission limit"); do not silently omit them. GPU instances on the 3B path must still attempt the 3A.9 GPU queries; mark them unavailable only when CMS is fully out of reach.dimensions[]Full call list and metric-loss declaration rules: references/degradation-and-validation.md § 3.
阅读**inspection-commands.md § 步骤3B**。
| 指标 | 是否可用 | 数据源 |
|---|---|---|
| CPU / 内存* / 网络 / IO BPS+IOPS | ✓ | DescribeInstanceMonitorData |
| 单磁盘BPS + IOPS + 延迟 | ✓ | DescribeDiskMonitorData |
| 系统负载 / 磁盘使用率百分比 | ✗ | 不可用(标记为 |
| 进程级CPU / 内存(Top5) | ✗ | 仅3A路径可用 |
| GPU温度 / 使用率 / 内存占比 | ✗ | 仅3A路径可用 |
* 部分实例系列无法获取内存指标。
[必须 — 强制停止] 进入3B路径:一旦选择3B路径,终止所有调用。此路径下无法访问CloudMonitor;在3B路径内重新发起任何cms describe-metric-last命令均属禁止操作,会被标记为技能执行失败。路径切换为单向:3A → 3B,不可反向。cms[必须] 3B路径必须调用全部三个ECS API —— 仅调用容量相关API会导致技能执行失败:
—— 实例级CPU / 内存 / 网络 / IO数据aliyun ecs describe-instance-monitor-data —— 磁盘列表 + 容量信息aliyun ecs describe-disks —— 单磁盘BPS / IOPS / 延迟,需按aliyun ecs describe-disk-monitor-data逐个调用DiskId[必须] 强制并行模板 —— 将三个ECS API整合到单个shell调用中触发。将批处理拆分为单独工具调用会导致技能执行失败:bashaliyun ecs describe-instance-monitor-data --region-id $REGION --instance-id $INSTANCE_ID \ --start-time $START --end-time $END --period 60 \ > /tmp/ecs_3b_imd.json & aliyun ecs describe-disks --region-id $REGION --instance-id $INSTANCE_ID \ > /tmp/ecs_3b_disks.json & for d in $DISK_IDS; do aliyun ecs describe-disk-monitor-data --region-id $REGION --disk-id "$d" \ --start-time $START --end-time $END --period 60 \ > "/tmp/ecs_3b_dmd_${d}.json" & done wait完成后自检:wait、/tmp/ecs_3b_imd.json以及**至少一个/tmp/ecs_3b_disks.json**必须全部存在且非空。若执行的shell历史中缺少任一命令,需终止运行并标记为技能执行失败。/tmp/ecs_3b_dmd_*.json不可用指标必须在报告中明确声明(在中标记为dimensions[]);不得静默省略。处于3B路径的GPU实例仍需尝试3A.9 GPU查询;仅当完全无法访问CMS时才标记为不可用。"N/A — 因权限限制触发降级路径"完整调用列表和指标缺失声明规则:references/degradation-and-validation.md § 3。
Step 4: Disk Capacity (independent step, parallel with 3A/3B)
步骤4:磁盘容量(独立步骤,与3A/3B并行执行)
[Independent parallel step] This step is independent of whichever monitoring path was chosen. Regardless of 3A or 3B,MUST be executed to obtain disk-capacity information. Skipping it on the fallback path is forbidden.aliyun ecs describe-disks
Read inspection-commands.md § Step 4. Per disk, extract: / / / (system|data) / / .
DiskIdSizeCategoryTypeDeviceStatusOn the CloudMonitor path, merge the 3A.7 disk-usage % by mount point with the disk info gathered here.
[独立并行步骤] 此步骤独立于所选的监控路径。**无论走3A还是3B路径,必须执行**以获取磁盘容量信息。禁止在降级路径中跳过此步骤。aliyun ecs describe-disks
阅读**inspection-commands.md § 步骤4**。按磁盘提取: / / / (系统盘|数据盘)/ / 。
DiskIdSizeCategoryTypeDeviceStatus在CloudMonitor路径中,将3A.7获取的按挂载点统计的磁盘使用率与在此步骤收集的磁盘信息合并。
Step 5: Anomaly Detection
步骤5:异常检测
Threshold table:
| Metric | ⚠️ Warning | 🔴 Critical |
|---|---|---|
| CPU usage | > 80% avg | > 95% avg |
| System load | > CPU cores | > 2× CPU cores |
| Memory usage | > 80% | > 95% |
| Disk usage | > 80% | > 95% |
| Disk IOPS / BPS | Approaching instance limit | Above instance limit |
| GPU temperature | > 75°C | > 85°C |
| GPU utilization / memory | > 80% | > 95% |
Every anomaly must come with concrete remediation. If 3A.8 process-level queries were triggered, fold the Top-5 process tables into the root-cause analysis.
阈值表:
| 指标 | ⚠️ 警告 | 🔴 严重 |
|---|---|---|
| CPU使用率 | 平均>80% | 平均>95% |
| 系统负载 | > CPU核心数 | > 2× CPU核心数 |
| 内存使用率 | >80% | >95% |
| 磁盘使用率 | >80% | >95% |
| 磁盘IOPS / BPS | 接近实例限制 | 超过实例限制 |
| GPU温度 | >75°C | >85°C |
| GPU使用率 / 内存占比 | >80% | >95% |
每个异常必须附带具体的修复建议。若触发了3A.8进程级查询,需将Top5进程表整合到根因分析中。
Step 6: Render the HTML Report
步骤6:渲染HTML报告
Since 2026-05-12, the LLM emits structured JSON only; scripts/render_report.py renders the HTML, cutting end-to-end latency by ~50%.
Step 6.1 — Build the JSON
LLM-mandatory fields: / / / / / / / / / .
assessment.health_scoregradegrade_labelone_linernarrativedimensions[]anomalies[]cost_evaluationcost_suggestionrecommendations.{immediate,short_term,long_term}[]Full schema: .
python3 scripts/render_report.py --schema[MUST] JSON construction and validation:
- Required fields cannot be empty:
/dimensions[].value/anomalies[].detailmust not be empty strings; for empty data fillnarrative, never"N/A".null- [Data-loss guard] Before writing
/dimensions[], traverse every API response file you produced (metrics.*, the/tmp/ecs_3b_*.jsonpayloads, etc.). If a metric carries a valid numeric value in the raw response, you MUST surface that value; silently overwriting it ascms describe-metric-lastornullis a Skill failure (e.g. system-load values returned by 3A.2 must reach"N/A"and the correspondingmetrics.load.*row). The only legitimate triggers fordimensions[]are: (a) API returned empty"N/A"/ empty array, (b) HTTPDatapoints/403/404, or (c) the metric appears on the Step 3B unavailable list.InvalidAuthorizationis never permitted under any circumstance — usenull."N/A"- Type constraints:
/dimensions[].valuemust be plain numbers orcurrent. Range strings such as"N/A"or"99-100%"are forbidden."around 50%"- Unit enforcement: disk latency in
(NOTμs), network inms, IO throughput inbits/s.bytes/s- Grading logic:
/grademust strictly followgrade_label(e.g.,health_score→ A,>=90→ D,[40,59]→ F). A low score combined with a<40like "everything is fine" is forbidden.one_liner- Hard guard: if any
ormetrics.disk_latency.*field carries andisks[].latency_*suffix or has a value < 1, abort and fix immediately. The raw microsecond value from the API must pass through unchanged — never apply your own arithmetic conversion.msGrade-mapping table and full pre-validation checklist: references/degradation-and-validation.md § 4.
[MUST]is mandatory before rendering:--validatebashpython3 scripts/render_report.py --validate --input /tmp/ecs_inspect_data.jsonA non-zero exit code means the JSON must be fixed and re-validated until it passes — never render with broken data.
Step 6.2 — Invoke the renderer
[MUST] The LLM is forbidden from writing the HTML template or hand-assembling the report. All structured data MUST flow strictly through. Ifpython3 scripts/render_report.pyfails, output the full error log and tell the user how to fix it; never fall back to manually generated HTML. A render failure is a Skill failure.render_report.py
bash
cat > /tmp/ecs_inspect_data.json <<'JSON_EOF'
{ ... structured data produced by the LLM ... }
JSON_EOF
python3 scripts/render_report.py \
--input /tmp/ecs_inspect_data.json \
--output "ecs-${INSTANCE_ID}-inspection-report-$(date +%Y%m%d-%H%M%S).html"If the script returns a non-zero exit code:
- Print the full stderr.
- Cross-check the JSON against the schema ().
python3 scripts/render_report.py --schema - Fix the JSON and retry once.
- If it still fails, return the error to the user and run Step 7 to exit.
Step 6.3 — Naming convention: , saved to the workspace root.
ecs-{INSTANCE_ID}-inspection-report-{YYYYMMDD-HHMMSS}.html自2026-05-12起,LLM 仅输出结构化JSON;scripts/render_report.py负责渲染HTML,可将端到端延迟降低约50%。
步骤6.1 — 构建JSON
LLM必填字段: / / / / / / / / / 。
assessment.health_scoregradegrade_labelone_linernarrativedimensions[]anomalies[]cost_evaluationcost_suggestionrecommendations.{immediate,short_term,long_term}[]完整 schema:。
python3 scripts/render_report.py --schema[必须] JSON构建和验证:
- 必填字段不能为空:
/dimensions[].value/anomalies[].detail不得为空字符串;空数据填充narrative,禁止使用"N/A"。null- [数据丢失防护] 在写入
/dimensions[]前,遍历所有生成的API响应文件(metrics.*、/tmp/ecs_3b_*.jsonpayload等)。若原始响应中某指标包含有效数值,必须将该值展示出来;静默替换为cms describe-metric-last或null会导致技能执行失败(例如3A.2返回的系统负载值必须传递到"N/A"和对应的metrics.load.*行)。dimensions[]的唯一合法触发条件为:(a) API返回空"N/A"/ 空数组,(b) HTTP返回Datapoints/403/404,或(c) 该指标在步骤3B的不可用列表中。任何情况下均禁止使用InvalidAuthorization—— 请使用null。"N/A"- 类型约束:
/dimensions[].value必须为纯数字或current。禁止使用范围字符串如"N/A"或"99-100%"。"约50%"- 单位强制要求:磁盘延迟单位为
(禁止使用μs),网络单位为ms,IO吞吐量单位为bits/s。bytes/s- 评分逻辑:
/grade必须严格遵循grade_label(例如health_score→ A,>=90→ D,[40,59]→ F)。禁止出现低评分搭配<40为"一切正常"的情况。one_liner- 强制防护:若任何
或metrics.disk_latency.*字段带有disks[].latency_*后缀或值<1,需立即终止并修复。必须直接传递API返回的原始微秒值 —— 不得自行进行算术转换。ms评分映射表和完整预验证 checklist:references/degradation-and-validation.md § 4。
[必须] 渲染前必须执行:--validatebashpython3 scripts/render_report.py --validate --input /tmp/ecs_inspect_data.json非零退出码表示JSON必须修复并重新验证,直至通过 —— 切勿使用损坏的数据进行渲染。
步骤6.2 — 调用渲染器
[必须] 禁止LLM编写HTML模板或手动组装报告。 所有结构化数据必须严格通过流转。若python3 scripts/render_report.py执行失败,需输出完整错误日志并告知用户修复方法;禁止回退到手动生成HTML。渲染失败视为技能执行失败。render_report.py
bash
cat > /tmp/ecs_inspect_data.json <<'JSON_EOF'
{ ... LLM生成的结构化数据 ... }
JSON_EOF
python3 scripts/render_report.py \
--input /tmp/ecs_inspect_data.json \
--output "ecs-${INSTANCE_ID}-inspection-report-$(date +%Y%m%d-%H%M%S).html"若脚本返回非零退出码:
- 打印完整标准错误输出。
- 将JSON与schema交叉验证()。
python3 scripts/render_report.py --schema - 修复JSON并重试一次。
- 若仍失败,向用户返回错误信息并执行步骤7退出。
步骤6.3 — 命名规范:,保存到工作区根目录。
ecs-{INSTANCE_ID}-inspection-report-{YYYYMMDD-HHMMSS}.htmlStep 7: Cleanup & Disable AI-Mode ([MUST] every exit point)
步骤7:清理 & 禁用AI模式([必须] 所有退出点)
[MUST] On every exit — success, failure, cancel, or any exception — always run:bashaliyun configure ai-mode disable 2>/dev/null || true rm -f /tmp/ecs_inspect_*.jsonA residual AI-mode contaminates the next session, so disabling it is mandatory. This skill is read-only — no cloud-side cleanup is needed.
[必须] 在任何退出场景下 —— 成功、失败、取消或任何异常 —— 必须执行:bashaliyun configure ai-mode disable 2>/dev/null || true rm -f /tmp/ecs_inspect_*.json残留的AI模式会污染下一个会话,因此禁用操作是必须的。本技能为只读操作 —— 无需清理云端资源。
Success Verification
成功验证
End-to-end acceptance:
- The instance exists and ✓
Status=Running - Step 3A or 3B returned at least one valid metric ✓
- Step 4 returned at least the system disk ✓
- The Step 6 HTML file is > 5 KB ✓
- Step 7 has disabled AI-mode ✓
If any item fails, tell the user the failure reason. Never fabricate data.
端到端验收标准:
- 实例存在且✓
Status=Running - 步骤3A或3B返回至少一个有效指标 ✓
- 步骤4返回至少系统盘信息 ✓
- 步骤6生成的HTML文件大小>5 KB ✓
- 步骤7已禁用AI模式 ✓
若任何项失败,告知用户失败原因。禁止编造数据。
Cleanup
清理
This skill is read-only — there are no cloud resources to reclaim. Step 7 already covers the local cleanup:
aliyun configure ai-mode disable- Remove the intermediate files
/tmp/ecs_inspect_*.json
The HTML report stays in the workspace root; the user decides whether to keep it.
本技能为只读操作 —— 无需回收云端资源。步骤7已覆盖本地清理:
aliyun configure ai-mode disable- 删除中间文件
/tmp/ecs_inspect_*.json
HTML报告保留在工作区根目录,由用户决定是否保留。
Command Tables
命令表
Full CLI command list and field semantics: references/inspection-commands.md. Quick view of the common product/action pairs:
| Product | Command | Purpose |
|---|---|---|
| ecs | | Instance existence + spec |
| ecs | | Disk capacity + mount mapping |
| ecs | | Instance monitoring data (fallback path) |
| ecs | | Per-disk monitoring data (fallback path) |
| cms | | Agent-status decision |
| cms | | Full metric query (primary path) |
完整CLI命令列表和字段语义:references/inspection-commands.md。常用产品/操作对快速查看:
| 产品 | 命令 | 用途 |
|---|---|---|
| ecs | | 实例存在性 + 规格信息 |
| ecs | | 磁盘容量 + 挂载映射 |
| ecs | | 实例监控数据(降级路径) |
| ecs | | 单磁盘监控数据(降级路径) |
| cms | | Agent状态决策 |
| cms | | 全指标查询(主路径) |
Best Practices
最佳实践
- Always confirm parameters first — never start running without Instance ID and Region ID.
- Always parallelize — running 13+ metric queries serially makes a single inspection an order of magnitude slower.
- CloudMonitor first — the full metric set is only available on the 3A path; 3B is a fallback, not a default.
- Empty data is — no fabrication, no extrapolation, no "close enough".
"N/A" - Process queries only when CPU/Memory > 80% — the process-level API is expensive; skip it when there is no anomaly.
- CMS plugin is required for kebab-case — once 0.3.0+ is installed, CMS supports plugin-mode kebab-case. The
aliyun-cli-cms+auto-plugin-install truein the Installation section already handle this. The plugin notice at the top ofaliyun plugin updateconfirms it is active.aliyun cms --help - AI-mode must be disabled — Step 7 must be executed at every exit point so AI-mode does not leak into the next session.
- The LLM does not assemble HTML — the LLM only produces JSON; template assembly is delegated to render_report.py. A render failure is a Skill failure — return the error reason and remediation to the user; never bypass the script and emit HTML by hand.
- 始终先确认参数 —— 未获取实例ID和地域ID前切勿开始执行。
- 始终并行执行 —— 串行执行13+个指标查询会使单次检查速度慢一个数量级。
- 优先使用CloudMonitor —— 完整指标集仅在3A路径可用;3B是降级路径,而非默认路径。
- 空数据标记为—— 禁止编造、推断或使用"近似值"。
"N/A" - 仅当CPU/内存>80%时执行进程查询 —— 进程级API开销较大;无异常时跳过。
- CMS插件是短横线命名的必要条件 —— 安装0.3.0+后,CMS支持插件模式短横线命名。安装部分的
aliyun-cli-cms+auto-plugin-install true已处理此配置。aliyun plugin update顶部的插件通知可确认其已激活。aliyun cms --help - 必须禁用AI模式 —— 步骤7必须在所有退出点执行,避免AI模式泄漏到下一个会话。
- LLM不得组装HTML —— LLM仅生成JSON;模板组装由render_report.py负责。渲染失败视为技能执行失败 —— 向用户返回错误原因和修复方法;禁止绕过脚本手动生成HTML。
References
参考文档
| File | Purpose |
|---|---|
| references/inspection-commands.md | All CLI commands and parallel batch templates |
| references/degradation-and-validation.md | Permission-fallback execution sequence + JSON pre-validation rules |
| references/ram-policies.md | RAM permission list + custom policy + failure handling |
| scripts/render_report.py | HTML rendering script (stdlib only) |
| scripts/requirements.txt | Canonical Python dependency declaration for |
| 文件 | 用途 |
|---|---|
| references/inspection-commands.md | 所有CLI命令和并行批处理模板 |
| references/degradation-and-validation.md | 权限降级执行序列 + JSON预验证规则 |
| references/ram-policies.md | RAM权限列表 + 自定义策略 + 失败处理 |
| scripts/render_report.py | HTML渲染脚本(仅使用标准库) |
| scripts/requirements.txt | |