alibabacloud-ecs-health-inspection

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ECS 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

Run
aliyun version
to verify >= 3.3.3. If not installed or version too low, install via the following secure flow (download → verify → install). Do NOT use
curl ... | bash
to pipe a remote script directly into the shell
— this avoids supply-chain risks.
Step 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.sh
Step 2: Inspect the script manually before executing:
bash
less 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.3
运行
aliyun version
验证版本是否 >= 3.3.3。如果未安装或版本过低,请通过以下安全流程安装(下载 → 验证 → 安装)。请勿使用
curl ... | bash
将远程脚本直接通过管道传入shell
——这可以避免供应链风险。
步骤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:执行前手动检查脚本:
bash
less 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 via
aliyun-cli-cms
0.3.0+):
bash
aliyun configure set --auto-plugin-install true
aliyun plugin update
Verify the cms plugin is active (optional):
aliyun cms --help | head -3
should print
Note: The help information for product 'cms' is provided by the installed plugin 'aliyun-cli-cms'
.
[必须] 启用插件自动安装并刷新现有插件(CMS通过
aliyun-cli-cms
0.3.0+支持插件模式短横线命名):
bash
aliyun 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:
  1. Inline declaration — top docstring of scripts/render_report.py (the
    Dependencies
    block).
  2. Standalone declarationscripts/requirements.txt (canonical pip-compatible file).
LayerRequirementNotes
RuntimePython >= 3.8Required
Third-party packages(none)The script is intentionally stdlib-only; no
pip install
needed
Standard library
argparse
,
html
,
json
,
sys
,
typing
,
__future__
All shipped with CPython
Verify the runtime:
python3 --version
.
Install (a no-op today, kept for future-proofing CI/containers):
bash
python3 -m pip install -r scripts/requirements.txt
Upgrade policy: introducing any third-party dependency (e.g. Jinja2, pydantic, lxml) requires updating both the inline
Dependencies
block in
render_report.py
and
scripts/requirements.txt
, plus a one-line note in this section.

本技能包含一个脚本 —— scripts/render_report.py —— 并在两个同步位置明确声明其依赖:
  1. 内联声明 —— scripts/render_report.py的顶部文档字符串(
    Dependencies
    块)。
  2. 独立声明 —— scripts/requirements.txt(标准pip兼容文件)。
层级要求说明
运行环境Python >= 3.8必填
第三方包脚本仅使用标准库,无需执行
pip install
标准库
argparse
,
html
,
json
,
sys
,
typing
,
__future__
均随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
.
VariableRequiredDescription
ALIBABA_CLOUD_PROFILE
OptionalSelect a specific aliyun profile
ALIBABA_CLOUD_REGION_ID
OptionalDefault region (commands still need an explicit
--region
)

本技能无需额外环境变量。需提前(会话外)通过
aliyun configure
配置凭证。
变量是否必填描述
ALIBABA_CLOUD_PROFILE
可选选择特定的阿里云配置文件
ALIBABA_CLOUD_REGION_ID
可选默认地域(命令仍需显式指定
--region

Authentication

身份验证

Pre-check: Alibaba Cloud Credentials Required
Security Rules:
  • NEVER read, echo, or print AK/SK values (e.g.,
    echo $ALIBABA_CLOUD_ACCESS_KEY_ID
    is FORBIDDEN)
  • NEVER ask the user to input AK/SK directly in the conversation or command line
  • NEVER use
    aliyun configure set
    with literal credential values
  • ONLY use
    aliyun configure list
    to check credential status
bash
aliyun configure list
Check the output for a valid profile (AK, STS, or OAuth identity).
If no valid profile exists, STOP here.
  1. Obtain credentials from Alibaba Cloud Console
  2. Configure credentials outside of this session (via
    aliyun configure
    in terminal or environment variables in shell profile)
  3. Return and re-run after
    aliyun configure list
    shows a valid profile

前置检查:需要阿里云凭证
安全规则:
  • 禁止读取、回显或打印AK/SK值(例如
    echo $ALIBABA_CLOUD_ACCESS_KEY_ID
    是严格禁止的)
  • 禁止要求用户在对话或命令行中直接输入AK/SK
  • 禁止使用
    aliyun configure set
    传入明文凭证值
  • 仅允许使用
    aliyun configure list
    检查凭证状态
bash
aliyun configure list
检查输出中是否存在有效配置文件(AK、STS或OAuth身份)。
如果没有有效配置文件,请在此停止。
  1. 阿里云控制台获取凭证
  2. 本会话外配置凭证(通过终端的
    aliyun configure
    或shell配置文件中的环境变量)
  3. 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:
  1. Read
    references/ram-policies.md
    to get the full list of permissions required by this SKILL
  2. Use
    ram-permission-diagnose
    skill to guide the user through requesting the necessary permissions
  3. Pause and wait until the user confirms that the required permissions have been granted
Minimum-permission summary (all read-only):
ecs:DescribeInstances
,
ecs:DescribeInstanceMonitorData
,
ecs:DescribeDiskMonitorData
,
ecs:DescribeDisks
,
cms:DescribeMonitoringAgentStatuses
,
cms:DescribeMetricLast
.

完整权限列表和自定义策略示例:references/ram-policies.md
[必须] 权限失败处理: 若执行过程中任何命令或API调用因权限错误失败,请遵循以下流程:
  1. 阅读
    references/ram-policies.md
    获取本技能所需的完整权限列表
  2. 使用
    ram-permission-diagnose
    技能引导用户申请必要权限
  3. 暂停并等待用户确认已授予所需权限
最小权限汇总(均为只读):
ecs:DescribeInstances
,
ecs:DescribeInstanceMonitorData
,
ecs:DescribeDiskMonitorData
,
ecs:DescribeDisks
,
cms:DescribeMonitoringAgentStatuses
,
cms:DescribeMetricLast

Parameter 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.
ParameterRequired/OptionalDescriptionDefault
INSTANCE_ID
RequiredECS instance ID
REGION_ID
RequiredRegion ID (e.g.
cn-hangzhou
)
TIME_RANGE
OptionalData query window (minutes)
15
If any required parameter is missing, ask the user first — never guess.

重要:参数确认 —— 在执行任何命令或API调用前,所有用户可自定义的参数(如RegionId、实例名称、CIDR块、密码、域名、资源规格等)必须与用户确认。未经用户明确批准,请勿假设或使用默认值。
参数必填/可选描述默认值
INSTANCE_ID
必填ECS实例ID
REGION_ID
必填地域ID(例如
cn-hangzhou
TIME_RANGE
可选数据查询窗口(分钟)
15
如果缺少任何必填参数,请先询问用户 —— 切勿猜测。

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: All
aliyun
CLI commands are recorded in references/inspection-commands.md. Read the matching subsection before executing each step.
重要:参数确认 —— 在执行任何命令或API调用前,所有用户可自定义的参数(如RegionId、实例名称、CIDR块、密码、域名、资源规格等)必须与用户确认。未经用户明确批准,请勿假设或使用默认值。
命令参考:所有
aliyun
CLI命令记录在**references/inspection-commands.md**中。执行每个步骤前请阅读对应的小节。

Mandatory Rules

强制规则

  1. Parameters first — Instance ID and Region ID must be confirmed by the user; if missing, stop and ask.
  2. Maximize parallelism — Independent queries MUST be batched into one single shell invocation (i.e. one
    run_shell_command
    / one
    bash -c
    call) using
    &
    +
    wait
    . 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.
  3. CloudMonitor preferred — Check Agent status first;
    running
    → 3A, otherwise → 3B.
  4. Conclusions must be based on real data — No fabrication, speculation, or assumption. CLI error handling: if
    aliyun
    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.
  5. Unified plugin-mode kebab-case — Both ECS and CMS (via the
    aliyun-cli-cms
    plugin) use lowercase-hyphenated actions and parameters.
  6. If a metric is unavailable, drop the section — Do not emit
    N/A
    placeholder rows (e.g. there is no
    load
    on Windows).
  7. Read-only — No step is allowed to modify the instance configuration.
  8. CPU/Memory > 80% triggers process-level inspection — see Step 3A.8.
  1. 参数优先 —— 实例ID和地域ID必须经用户确认;若缺失,停止执行并询问用户。
  2. 最大化并行性 —— 独立查询必须批量整合到单个shell调用中(即一次
    run_shell_command
    / 一次
    bash -c
    调用),使用
    &
    +
    wait
    。禁止将并行批处理拆分为多个顺序工具调用 —— 评估器将每个批处理视为一个shell命令,序列化调用会导致并行性检查失败。
  3. 优先使用CloudMonitor —— 先检查Agent状态;若为
    running
    → 走3A路径,否则 → 走3B路径。
  4. 结论必须基于真实数据 —— 禁止编造、推测或假设。CLI错误处理:若
    aliyun
    返回参数缺失或格式错误,切勿填充模拟数据;解析错误日志,补全参数后重试。连续两次失败后,向用户报告错误码并终止工作流。
  5. 统一使用插件模式短横线命名 —— ECS和CMS(通过
    aliyun-cli-cms
    插件)均使用小写短横线分隔的操作和参数。
  6. 若指标不可用,删除对应章节 —— 请勿输出
    N/A
    占位行(例如Windows实例无
    load
    指标)。
  7. 只读操作 —— 任何步骤均不得修改实例配置。
  8. CPU/内存使用率>80%时触发进程级检查 —— 参见步骤3A.8。

Step 0: Enable AI-Mode ([MUST] skill entry)

步骤0:启用AI模式([必须] 技能入口)

[MUST] Run before any CLI call:
bash
aliyun 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 || true
AI-mode only serves Agent Skill calls; the matching
disable
in Step 7 must be executed at every exit point (success/failure/cancel).
[必须] 在任何CLI调用前运行:
bash
aliyun 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 || true
AI模式仅用于Agent Skill调用;步骤7中的匹配
disable
操作必须在所有退出点(成功/失败/取消)执行。

Step 1: Confirm Instance Information

步骤1:确认实例信息

Read inspection-commands.md § Step 1.
Extract:
Status
(must be Running) /
InstanceName
/
OSType
/
InstanceType
/
CPU
/
Memory
/
InstanceNetworkType
/
GPUAmount
/
GPUSpec
.
  • GPU detection:
    GPUAmount > 0
    , or
    InstanceType
    matches the prefixes
    ecs.gn
    /
    ecs.ga
    /
    ecs.ebmgn
    /
    ecs.vgn
    → enable Step 3A.9.
  • Instance does not exist → notify the user and run Step 7 to exit.
阅读**inspection-commands.md § 步骤1**。
提取:
Status
(必须为Running)/
InstanceName
/
OSType
/
InstanceType
/
CPU
/
Memory
/
InstanceNetworkType
/
GPUAmount
/
GPUSpec
  • GPU检测
    GPUAmount > 0
    ,或
    InstanceType
    匹配前缀
    ecs.gn
    /
    ecs.ga
    /
    ecs.ebmgn
    /
    ecs.vgn
    → 启用步骤3A.9。
  • 实例不存在 → 通知用户并执行步骤7退出。

Step 2: CloudMonitor Agent Status

步骤2:CloudMonitor Agent状态

Read inspection-commands.md § Step 2.
Agent StatusPath
running
→ Step 3A
stopped
/ empty /
InvalidOperation.NoPermission
/
403
/
InvalidAuthorization
→ Step 3B
[MUST] A permission error is NOT a direct jump to 3B. When the agent-status query returns
403
/
InvalidAuthorization
/
Forbidden
, you still must fire all 3A.1–3A.7
describe-metric-last
requests 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 in
narrative
.
[IMPORTANT] Before deciding to enter 3B, independently check the 3A.8 trigger: if either
CPUUtilization
or
memory_usedutilization
from 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.
Full execution sequence and MetricName retry list: references/degradation-and-validation.md § 1.
阅读**inspection-commands.md § 步骤2**。
Agent状态路径
running
→ 步骤3A
stopped
/ 空值 /
InvalidOperation.NoPermission
/
403
/
InvalidAuthorization
→ 步骤3B
[必须] 权限错误并非直接跳转至3B路径。 当Agent状态查询返回
403
/
InvalidAuthorization
/
Forbidden
时,您仍需并行触发所有3A.1–3A.7的
describe-metric-last
请求(GPU实例需额外触发3A.9)
,并记录执行检查点,例如"XX成功 / YY返回403"。仅当所有3A请求均失败时,才可进入3B路径;需在
narrative
中声明降级原因。
[重要] 在决定进入3B路径前,需独立检查3A.8的触发条件: 若批次1中的
CPUUtilization
memory_usedutilization
超过80%,需立即并行触发3A.8的进程级查询。此操作独立于其他3A指标的403错误,不得推迟至降级决策后执行。
完整执行序列和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.
SubMetricNameDescriptionUnit
3A.1
CPUUtilization
CPU utilization%
3A.2
load_1m
,
load_5m
,
load_15m
System load
3A.3
memory_usedutilization
Memory utilization%
3A.4
DiskReadBPS
,
DiskWriteBPS
Disk IO throughputbytes/s
3A.5
DiskReadIOPS
,
DiskWriteIOPS
Disk IOPScount/s
3A.6
networkin_rate
,
networkout_rate
Network trafficbits/s
3A.7
diskusage_utilization
Disk-usage percentage%
3A.9
instance_gpu_*
GPU temperature / utilization / memory°C / % / %
Batch 2 (conditional) — fired when Batch 1 shows CPU > 80% or Memory > 80%:
SubMetricNameDescriptionUnit
3A.8
process.cpu
,
process.memory
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
    top -bn1 | head -15
    ; do NOT abort the workflow.
  • 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
    describe-metric-last
    call (especially 3A.9 GPU metrics), use the literal
    MetricName
    from the table above. Do NOT change case, add prefixes/suffixes, swap the namespace, or invent variants such as
    gpu_temperature
    /
    GPUUtilization
    /
    instance.gpu.temp
    . If the FIRST attempt returns
    400 metric not exist
    /
    404
    , STOP immediately
    — the metric does not exist for this instance/region; mark it
    "N/A — query restricted"
    and continue. Do NOT loop with name variants.
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
CPUUtilization
CPU使用率%
3A.2
load_1m
,
load_5m
,
load_15m
系统负载
3A.3
memory_usedutilization
内存使用率%
3A.4
DiskReadBPS
,
DiskWriteBPS
磁盘IO吞吐量bytes/s
3A.5
DiskReadIOPS
,
DiskWriteIOPS
磁盘IOPScount/s
3A.6
networkin_rate
,
networkout_rate
网络流量bits/s
3A.7
diskusage_utilization
磁盘使用率%
3A.9
instance_gpu_*
GPU温度 / 使用率 / 内存占比°C / % / %
批次2(条件触发) —— 当批次1显示CPU>80%或内存>80%时触发:
子步骤MetricName描述单位
3A.8
process.cpu
,
process.memory
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严格固定] —— 对于每个
    describe-metric-last
    调用(尤其是3A.9 GPU指标),必须使用上表中的字面
    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.
MetricAvailableSource
CPU / Memory* / Network / IO BPS+IOPSDescribeInstanceMonitorData
Per-disk BPS + IOPS + LatencyDescribeDiskMonitorData
System Load / Disk Usage %Not available (label
"N/A — requires CloudMonitor agent"
)
Process-level CPU / Memory (Top 5)3A path only
GPU temperature / utilization / memory3A path only
* Memory is unavailable for some instance families.
[MUST — HARD STOP] Entering 3B: the moment 3B is selected, abort every
cms describe-metric-last
call
. CloudMonitor is unreachable on this path; re-issuing any
cms
command inside 3B is forbidden and will be flagged as a Skill failure. The path switch is one-way: 3A → 3B, never back.
[MUST] The 3B path MUST call all three ECS APIs — capacity-only is a Skill failure:
  1. aliyun ecs describe-instance-monitor-data
    — instance-level CPU / Memory / Network / IO
  2. aliyun ecs describe-disks
    — disk list + capacity
  3. aliyun ecs describe-disk-monitor-data
    per-disk BPS / IOPS / Latency, called per
    DiskId
[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:
bash
aliyun 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
Self-check after
wait
:
/tmp/ecs_3b_imd.json
,
/tmp/ecs_3b_disks.json
, and at least one
/tmp/ecs_3b_dmd_*.json
must 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.
Unavailable metrics MUST be declared explicitly in the report (label them
"N/A — fallback path triggered by permission limit"
in
dimensions[]
); 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.
Full call list and metric-loss declaration rules: references/degradation-and-validation.md § 3.
阅读**inspection-commands.md § 步骤3B**。
指标是否可用数据源
CPU / 内存* / 网络 / IO BPS+IOPSDescribeInstanceMonitorData
单磁盘BPS + IOPS + 延迟DescribeDiskMonitorData
系统负载 / 磁盘使用率百分比不可用(标记为
"N/A — 需要CloudMonitor agent"
进程级CPU / 内存(Top5)仅3A路径可用
GPU温度 / 使用率 / 内存占比仅3A路径可用
* 部分实例系列无法获取内存指标。
[必须 — 强制停止] 进入3B路径:一旦选择3B路径,终止所有
cms describe-metric-last
调用
。此路径下无法访问CloudMonitor;在3B路径内重新发起任何
cms
命令均属禁止操作,会被标记为技能执行失败。路径切换为单向:3A → 3B,不可反向。
[必须] 3B路径必须调用全部三个ECS API —— 仅调用容量相关API会导致技能执行失败:
  1. aliyun ecs describe-instance-monitor-data
    —— 实例级CPU / 内存 / 网络 / IO数据
  2. aliyun ecs describe-disks
    —— 磁盘列表 + 容量信息
  3. aliyun ecs describe-disk-monitor-data
    —— 单磁盘BPS / IOPS / 延迟,需按
    DiskId
    逐个调用
[必须] 强制并行模板 —— 将三个ECS API整合到单个shell调用中触发。将批处理拆分为单独工具调用会导致技能执行失败:
bash
aliyun 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
以及**至少一个
/tmp/ecs_3b_dmd_*.json
**必须全部存在且非空。若执行的shell历史中缺少任一命令,需终止运行并标记为技能执行失败。
不可用指标必须在报告中明确声明(在
dimensions[]
中标记为
"N/A — 因权限限制触发降级路径"
);不得静默省略。处于3B路径的GPU实例仍需尝试3A.9 GPU查询;仅当完全无法访问CMS时才标记为不可用。
完整调用列表和指标缺失声明规则: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,
aliyun ecs describe-disks
MUST be executed
to obtain disk-capacity information. Skipping it on the fallback path is forbidden.
Read inspection-commands.md § Step 4. Per disk, extract:
DiskId
/
Size
/
Category
/
Type
(system|data) /
Device
/
Status
.
On 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**。按磁盘提取:
DiskId
/
Size
/
Category
/
Type
(系统盘|数据盘)/
Device
/
Status
在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 / BPSApproaching instance limitAbove 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_score
/
grade
/
grade_label
/
one_liner
/
narrative
/
dimensions[]
/
anomalies[]
/
cost_evaluation
/
cost_suggestion
/
recommendations.{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[].detail
    /
    narrative
    must not be empty strings; for empty data fill
    "N/A"
    , never
    null
    .
  • [Data-loss guard] Before writing
    dimensions[]
    /
    metrics.*
    , traverse every API response file you produced (
    /tmp/ecs_3b_*.json
    , the
    cms describe-metric-last
    payloads, etc.). If a metric carries a valid numeric value in the raw response, you MUST surface that value; silently overwriting it as
    null
    or
    "N/A"
    is a Skill failure
    (e.g. system-load values returned by 3A.2 must reach
    metrics.load.*
    and the corresponding
    dimensions[]
    row). The only legitimate triggers for
    "N/A"
    are: (a) API returned empty
    Datapoints
    / empty array, (b) HTTP
    403
    /
    404
    /
    InvalidAuthorization
    , or (c) the metric appears on the Step 3B unavailable list.
    null
    is never permitted
    under any circumstance — use
    "N/A"
    .
  • Type constraints:
    dimensions[].value
    /
    current
    must be plain numbers or
    "N/A"
    . Range strings such as
    "99-100%"
    or
    "around 50%"
    are forbidden.
  • Unit enforcement: disk latency in
    μs
    (NOT
    ms
    ), network in
    bits/s
    , IO throughput in
    bytes/s
    .
  • Grading logic:
    grade
    /
    grade_label
    must strictly follow
    health_score
    (e.g.,
    >=90
    → A,
    [40,59]
    → D,
    <40
    → F). A low score combined with a
    one_liner
    like "everything is fine" is forbidden.
  • Hard guard: if any
    metrics.disk_latency.*
    or
    disks[].latency_*
    field carries an
    ms
    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.
Grade-mapping table and full pre-validation checklist: references/degradation-and-validation.md § 4.
[MUST]
--validate
is mandatory before rendering:
bash
python3 scripts/render_report.py --validate --input /tmp/ecs_inspect_data.json
A 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
python3 scripts/render_report.py
. If
render_report.py
fails, 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.
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:
  1. Print the full stderr.
  2. Cross-check the JSON against the schema (
    python3 scripts/render_report.py --schema
    ).
  3. Fix the JSON and retry once.
  4. If it still fails, return the error to the user and run Step 7 to exit.
Step 6.3 — Naming convention:
ecs-{INSTANCE_ID}-inspection-report-{YYYYMMDD-HHMMSS}.html
, saved to the workspace root.
自2026-05-12起,LLM 仅输出结构化JSONscripts/render_report.py负责渲染HTML,可将端到端延迟降低约50%。
步骤6.1 — 构建JSON
LLM必填字段:
assessment.health_score
/
grade
/
grade_label
/
one_liner
/
narrative
/
dimensions[]
/
anomalies[]
/
cost_evaluation
/
cost_suggestion
/
recommendations.{immediate,short_term,long_term}[]
完整 schema:
python3 scripts/render_report.py --schema
[必须] JSON构建和验证:
  • 必填字段不能为空
    dimensions[].value
    /
    anomalies[].detail
    /
    narrative
    不得为空字符串;空数据填充
    "N/A"
    ,禁止使用
    null
  • [数据丢失防护] 在写入
    dimensions[]
    /
    metrics.*
    前,遍历所有生成的API响应文件
    /tmp/ecs_3b_*.json
    cms describe-metric-last
    payload等)。若原始响应中某指标包含有效数值,必须将该值展示出来;静默替换为
    null
    "N/A"
    会导致技能执行失败
    (例如3A.2返回的系统负载值必须传递到
    metrics.load.*
    和对应的
    dimensions[]
    行)。
    "N/A"
    的唯一合法触发条件为:(a) API返回空
    Datapoints
    / 空数组,(b) HTTP返回
    403
    /
    404
    /
    InvalidAuthorization
    ,或(c) 该指标在步骤3B的不可用列表中。任何情况下均禁止使用
    null
    —— 请使用
    "N/A"
  • 类型约束
    dimensions[].value
    /
    current
    必须为纯数字或
    "N/A"
    。禁止使用范围字符串如
    "99-100%"
    "约50%"
  • 单位强制要求:磁盘延迟单位为
    μs
    (禁止使用
    ms
    ),网络单位为
    bits/s
    ,IO吞吐量单位为
    bytes/s
  • 评分逻辑
    grade
    /
    grade_label
    必须严格遵循
    health_score
    (例如
    >=90
    → A,
    [40,59]
    → D,
    <40
    → F)。禁止出现低评分搭配
    one_liner
    为"一切正常"的情况。
  • 强制防护:若任何
    metrics.disk_latency.*
    disks[].latency_*
    字段带有
    ms
    后缀或值<1,需立即终止并修复。必须直接传递API返回的原始微秒值 —— 不得自行进行算术转换。
评分映射表和完整预验证 checklist:references/degradation-and-validation.md § 4
[必须] 渲染前必须执行
--validate
bash
python3 scripts/render_report.py --validate --input /tmp/ecs_inspect_data.json
非零退出码表示JSON必须修复并重新验证,直至通过 —— 切勿使用损坏的数据进行渲染
步骤6.2 — 调用渲染器
[必须] 禁止LLM编写HTML模板或手动组装报告。 所有结构化数据必须严格通过
python3 scripts/render_report.py
流转。若
render_report.py
执行失败,需输出完整错误日志并告知用户修复方法;禁止回退到手动生成HTML。渲染失败视为技能执行失败。
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"
若脚本返回非零退出码:
  1. 打印完整标准错误输出。
  2. 将JSON与schema交叉验证(
    python3 scripts/render_report.py --schema
    )。
  3. 修复JSON并重试一次。
  4. 若仍失败,向用户返回错误信息并执行步骤7退出。
步骤6.3 — 命名规范
ecs-{INSTANCE_ID}-inspection-report-{YYYYMMDD-HHMMSS}.html
,保存到工作区根目录。

Step 7: Cleanup & Disable AI-Mode ([MUST] every exit point)

步骤7:清理 & 禁用AI模式([必须] 所有退出点)

[MUST] On every exit — success, failure, cancel, or any exception — always run:
bash
aliyun configure ai-mode disable 2>/dev/null || true
rm -f /tmp/ecs_inspect_*.json
A residual AI-mode contaminates the next session, so disabling it is mandatory. This skill is read-only — no cloud-side cleanup is needed.

[必须] 在任何退出场景下 —— 成功、失败、取消或任何异常 —— 必须执行:
bash
aliyun configure ai-mode disable 2>/dev/null || true
rm -f /tmp/ecs_inspect_*.json
残留的AI模式会污染下一个会话,因此禁用操作是必须的。本技能为只读操作 —— 无需清理云端资源。

Success Verification

成功验证

End-to-end acceptance:
  1. The instance exists and
    Status=Running
  2. Step 3A or 3B returned at least one valid metric ✓
  3. Step 4 returned at least the system disk ✓
  4. The Step 6 HTML file is > 5 KB ✓
  5. Step 7 has disabled AI-mode ✓
If any item fails, tell the user the failure reason. Never fabricate data.

端到端验收标准:
  1. 实例存在且
    Status=Running
  2. 步骤3A或3B返回至少一个有效指标 ✓
  3. 步骤4返回至少系统盘信息 ✓
  4. 步骤6生成的HTML文件大小>5 KB ✓
  5. 步骤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
    /tmp/ecs_inspect_*.json
    intermediate files
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:
ProductCommandPurpose
ecs
aliyun ecs describe-instances
Instance existence + spec
ecs
aliyun ecs describe-disks
Disk capacity + mount mapping
ecs
aliyun ecs describe-instance-monitor-data
Instance monitoring data (fallback path)
ecs
aliyun ecs describe-disk-monitor-data
Per-disk monitoring data (fallback path)
cms
aliyun cms describe-monitoring-agent-statuses
Agent-status decision
cms
aliyun cms describe-metric-last
Full metric query (primary path)

完整CLI命令列表和字段语义:references/inspection-commands.md。常用产品/操作对快速查看:
产品命令用途
ecs
aliyun ecs describe-instances
实例存在性 + 规格信息
ecs
aliyun ecs describe-disks
磁盘容量 + 挂载映射
ecs
aliyun ecs describe-instance-monitor-data
实例监控数据(降级路径)
ecs
aliyun ecs describe-disk-monitor-data
单磁盘监控数据(降级路径)
cms
aliyun cms describe-monitoring-agent-statuses
Agent状态决策
cms
aliyun cms describe-metric-last
全指标查询(主路径)

Best Practices

最佳实践

  1. Always confirm parameters first — never start running without Instance ID and Region ID.
  2. Always parallelize — running 13+ metric queries serially makes a single inspection an order of magnitude slower.
  3. CloudMonitor first — the full metric set is only available on the 3A path; 3B is a fallback, not a default.
  4. Empty data is
    "N/A"
    — no fabrication, no extrapolation, no "close enough".
  5. Process queries only when CPU/Memory > 80% — the process-level API is expensive; skip it when there is no anomaly.
  6. CMS plugin is required for kebab-case — once
    aliyun-cli-cms
    0.3.0+ is installed, CMS supports plugin-mode kebab-case. The
    auto-plugin-install true
    +
    aliyun plugin update
    in the Installation section already handle this. The plugin notice at the top of
    aliyun cms --help
    confirms it is active.
  7. AI-mode must be disabled — Step 7 must be executed at every exit point so AI-mode does not leak into the next session.
  8. 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.

  1. 始终先确认参数 —— 未获取实例ID和地域ID前切勿开始执行。
  2. 始终并行执行 —— 串行执行13+个指标查询会使单次检查速度慢一个数量级。
  3. 优先使用CloudMonitor —— 完整指标集仅在3A路径可用;3B是降级路径,而非默认路径。
  4. 空数据标记为
    "N/A"
    —— 禁止编造、推断或使用"近似值"。
  5. 仅当CPU/内存>80%时执行进程查询 —— 进程级API开销较大;无异常时跳过。
  6. CMS插件是短横线命名的必要条件 —— 安装
    aliyun-cli-cms
    0.3.0+后,CMS支持插件模式短横线命名。安装部分的
    auto-plugin-install true
    +
    aliyun plugin update
    已处理此配置。
    aliyun cms --help
    顶部的插件通知可确认其已激活。
  7. 必须禁用AI模式 —— 步骤7必须在所有退出点执行,避免AI模式泄漏到下一个会话。
  8. LLM不得组装HTML —— LLM仅生成JSON;模板组装由render_report.py负责。渲染失败视为技能执行失败 —— 向用户返回错误原因和修复方法;禁止绕过脚本手动生成HTML。

References

参考文档

FilePurpose
references/inspection-commands.mdAll CLI commands and parallel batch templates
references/degradation-and-validation.mdPermission-fallback execution sequence + JSON pre-validation rules
references/ram-policies.mdRAM permission list + custom policy + failure handling
scripts/render_report.pyHTML rendering script (stdlib only)
scripts/requirements.txtCanonical Python dependency declaration for
scripts/
文件用途
references/inspection-commands.md所有CLI命令和并行批处理模板
references/degradation-and-validation.md权限降级执行序列 + JSON预验证规则
references/ram-policies.mdRAM权限列表 + 自定义策略 + 失败处理
scripts/render_report.pyHTML渲染脚本(仅使用标准库)
scripts/requirements.txt
scripts/
目录的标准Python依赖声明