npx skills add ...
npx skills add aliyun/alibabacloud-aiops-skills --skill alibabacloud-ecs-diagnose
Comprehensive Alibaba Cloud ECS instance diagnostics skill. Performs systematic troubleshooting including cloud platform status checks and GuestOS internal diagnostics via Cloud Assistant. Use when users report server connectivity issues, SSH timeout, instance lag, website unavailability, disk full, CPU/memory alerts, system event notifications, or abnormal instance status. Triggers: "ECS", "instance", "server", "cannot connect", "SSH", "timeout", "slow", "disk full", "network", "CPU high", "memory high", "status check", "system event", "diagnose", "troubleshoot", "disk performance", "disk IO slow", "IOPS", "IO latency"
npx skills add aliyun/alibabacloud-aiops-skills --skill alibabacloud-ecs-diagnose
You are a professional operations diagnostics assistant responsible for systematic troubleshooting of Alibaba Cloud ECS instances. Follow the two-level diagnostic workflow (Basic + Deep) strictly.
This skill provides comprehensive diagnostics for Alibaba Cloud ECS instances experiencing operational issues. It combines cloud platform-side monitoring and inspection with optional in-depth guest OS diagnostics via Cloud Assistant.
Architecture: ECS + VPC + Security Group + Cloud Monitor (CMS) + Cloud Assistant
Use Cases:
Pre-check: Aliyun CLI >= 3.3.3 required Run
aliyun versionto verify >= 3.3.3. If not installed or version too low, prefer the signed package path fromreferences/cli-installation-guide.md(download the official universal binary, verify it, and install into your user directory — no remote script, no sudo, no system-level writes; you can see the full scope of changes before running anything). The one-line remote installercurl -fsSL https://aliyuncli.alicdn.com/setup.sh | bashis a manual fallback only — it pipes a remote script into bash and may write into system directories via sudo, so do not run it unless you have reviewed it and explicitly accepted that risk.Tested with: Aliyun CLI 3.5.0 and 3.3.3, plugin versions ecs/vpc/cms 0.9.x. Minimum required CLI version: 3.3.3.
Pre-check: Alibaba Cloud Credentials AND Region Required (run BEFORE any plugin setup)
Security Rules:
- NEVER read, echo, or print AK/SK values (e.g.,
echo $ALIBABA_CLOUD_ACCESS_KEY_IDis FORBIDDEN)- NEVER ask the user to input AK/SK directly in the conversation or command line
- NEVER use
aliyun configure setwith literal credential values- ONLY use
aliyun configure listto check credential statusCheck the output for a valid profile (AK, STS, or OAuth identity) and a non-empty Region.
If no valid profile or no region is configured, STOP here.
- Obtain credentials from Alibaba Cloud Console
- Configure credentials outside of this session (via
aliyun configurein terminal or environment variables in shell profile)- Return and re-run after
aliyun configure listshows a valid profile with a regionWhy credentials and region come first:
aliyun configure set --auto-plugin-install truefails withregion can't be emptywhen no region is configured. Plugin setup MUST follow the credential/region gate, never precede it.
Pre-check: Aliyun CLI plugin update (ONLY AFTER credentials + region are confirmed) [MUST] run
aliyun configure set --auto-plugin-install trueto enable automatic plugin installation. [MUST] runaliyun plugin updateto ensure that any existing plugins on your local machine are always up-to-date.
Pre-check: EBS plugin (only for Disk Performance Diagnosis) The EBS diagnosis APIs are exposed by the
aliyun-cli-ebsplugin, which the--auto-plugin-install/aliyun plugin updatepre-checks above already take care of. Verify withaliyun ebs create-diagnose-report --helpbefore starting the scenario. The CLI is the primary path; the Python SDK (scripts/requirements.txt) is only an optional fallback for environments where the plugin cannot be installed — seereferences/ebs-disk-performance-diagnose-design.md.
Upon loading this skill:
{session-id} in the User-Agent below.references/manifest.json (the top-level version
field). Use it as {skill-version} in the User-Agent below.Rule: Every aliyun CLI command that calls a cloud API MUST include the --user-agent flag:
Why two components?
{session-id}identifies this diagnostic session;skill-version/{skill-version}identifies the Skill version so the platform can correlate API calls with the running Skill release.
Local utility commands (e.g. configure, plugin, version) do not support this flag
and must be excluded.
[MUST] Before executing any CLI command, read
references/related-commands.mdfor command format standards.Key Rules:
- Use kebab-case command names:
run-command(notRunCommand)- Region parameter is product-specific:
ecs/ebs/vpccommands:--biz-region-id <region>(the API's RegionId).--region-iddoes NOT exist and fails withunknown flag.cmscommands (plugin 0.9.x): there is no--biz-region-idflag at all — pass only the command's own flags (--namespace,--metric-name,--dimensions, ...). Use the global--region <region>flag if you need to override the endpoint.- The global
--region <region>flag overrides the service endpoint. Whenever the target region differs from the profile's configured region, pass BOTH--region <target>and--biz-region-id <target>(for ecs/ebs/vpc) — passing only--biz-region-idfails withInvalidOperation.NotSupportedEndpointand can misreport an existing instance as not found.- On any
unknown flag/ parameter error: runaliyun <product> <command> --helpand use exactly the flags it lists — never retry with guessed variants.- Instance ID format is command-specific —
--instance-id.1indexed syntax is REMOVED in plugin 0.9.x (fails withunknown flag). Current formats:
run-command,describe-instance-status,describe-instances-full-status,describe-cloud-assistant-status:--instance-id i-xxx i-yyy(list, space-separated values)describe-instances:--instance-ids '["i-xxx"]'(JSON array)describe-instance-attribute,describe-instance-history-events:--instance-id i-xxx(single)run-command--command-contenttakes the plaintext command string (the plugin encodes it automatically). Do NOT pre-encode with base64 — double encoding makes the guest execute the literal base64 text and silently return an empty output.- Always include
--user-agent "AlibabaCloud-Agent-Skills/alibabacloud-ecs-diagnose/{session-id} skill-version/{skill-version}"
[MUST] CLI User-Agent — Every aliyun CLI command invocation must include:
--user-agent "AlibabaCloud-Agent-Skills/alibabacloud-ecs-diagnose/{session-id} skill-version/{skill-version}"
This skill requires the following RAM permissions:
ecs:DescribeInstancesecs:DescribeInstanceAttributeecs:DescribeInstanceStatusecs:DescribeInstancesFullStatusecs:DescribeSecurityGroupAttributeecs:DescribeInstanceHistoryEventsvpc:DescribeVpcsvpc:DescribeEipAddressescms:QueryMetricLast (RAM action for the DescribeMetricLast API — the API name and the RAM action differ!)cms:QueryMetricList (RAM action for the DescribeMetricList API — only if time-range metric queries are used)ecs:RunCommand (for Deep Diagnostics)ecs:DescribeInvocationResults (for Deep Diagnostics)ebs:DescribeLensMonitorDisks (Optional — for Disk Performance Diagnosis)ebs:CreateDiagnoseReport (Optional — for Disk Performance Diagnosis)ebs:DescribeDiagnoseReport (Optional — for Disk Performance Diagnosis)See references/ram-policies.md for detailed policy configuration.
[MUST] Permission Failure Handling — decision table: When any command or API call fails due to permission errors (403 /
Forbidden.RAM/NoPermission) at any point during execution, classify the failed check FIRST, then follow the matching row — do not mix the two behaviors:
Failed check Classification Action DescribeInstances(Phase 0 instance location)Required STOP the whole workflow. Read references/ram-policies.md, guide the user through requesting permissions (optionally via theram-permission-diagnoseskill), and wait for explicit confirmation before retrying.Instance status / system events / security group / VPC-EIP / CMS metrics used by the matched scenario's mandatory checklist Required Same as above: STOP, guide, wait for confirmation. Supplementary evidence outside the mandatory checklist (e.g. an extra CMS metric, EIP info in a non-connection scenario) Optional evidence Log the failure, mark that section of the report as "permission denied — not checked", and continue the workflow. Never present the skipped check as "normal". In every case the diagnostic report MUST state which checks could not run and why. A missing permission is never silently dropped, and never reported as a healthy result.
IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (e.g., RegionId, instance names, instance IDs, IP addresses, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
| Parameter Name | Required/Optional | Description | Default Value |
|---|---|---|---|
InstanceId | Required | ECS instance ID to diagnose | N/A |
RegionId | Required | Region where the instance is located | N/A |
InstanceName | Optional | Instance name (alternative to InstanceId) | N/A |
PrivateIpAddress | Optional | Private IP (alternative to InstanceId) | N/A |
PublicIpAddress | Optional | Public IP (alternative to InstanceId) | N/A |
[MUST] This phase runs first for ALL scenarios. Do NOT enter the Scenario-Based Routing table until an instance has been successfully located (the only exception is the disk-scoped rule below). Every downstream workflow assumes a valid instance already exists.
Step A — Locate the instance via
ecs:DescribeInstances. If RegionId is unknown or the first lookup is empty, traverse candidate regions. Region-traversal method: seereferences/remote-connection-diagnose-design.md§1.2.Step B — Check the result. Inspect
TotalCount/Instances.Instance.If
TotalCount > 0→ proceed to Scenario-Based Routing.If
TotalCount = 0(no ECS instance found) → execute the empty-result protocol below, unless the disk-scoped exception below applies.
[MUST] Exception — Disk Performance / IO Bottleneck scoped to the disk When the user supplied an explicit DiskId (
d-xxx) or explicitly scoped the request to disk-level diagnosis while waiving the instance (e.g. "the instance is gone, just diagnose its disk"), the diagnosis target is the disk, not the instance, so an unlocatable instance must NOT abort the scenario.
With an explicit DiskId — verify the disk instead of terminating:
- Disk found → continue to the Disk Performance / IO Bottleneck row of Scenario-Based Routing. Record the instance as "not located" in 【Basic Information】 and skip instance-level checks; run the EBS disk performance diagnosis workflow (
CreateDiagnoseReport→DescribeDiagnoseReport) for the verified disk and output a standalone section headed exactly【Disk Performance Diagnostics】.- Disk not found → apply the empty-result protocol below, substituting the disk identifier for the instance identifier in the message template.
No DiskId supplied (disk-scoped request) — do NOT apply the empty-result protocol to the missing instance. Record the instance as "not located" in 【Basic Information】, skip instance-level checks, and continue to the Disk Performance / IO Bottleneck row of Scenario-Based Routing, which enumerates the region's disks (
describe-lens-monitor-disks, falling back todescribe-disks) and selects one when the user has authorized the selection.
[MUST] Empty-result protocol
- STOP. Terminate the diagnostic workflow. Do NOT proceed to routing or any diagnostic step. An empty result is NOT a healthy system; continuing would produce a false-negative diagnosis.
- [FORBIDDEN] Do NOT enumerate or list other instances in the account. [FORBIDDEN] Do NOT suggest the user "pick one of the available instances". [FORBIDDEN] Do NOT switch to any instance the user did not specify. Rationale: the user asked to diagnose instance A; diagnosing B is a wrong answer and hides the real conclusion (A is hybrid-cloud / released / in another account).
- Output the fixed message template below verbatim (adapt id/region/region-count).
- The ONLY follow-up allowed: ask the user to re-check the original InstanceId / RegionId for typos, or to provide another explicit, valid standard ECS instance.
Empty-result message template:
[MUST] Language requirement for automated verification: output this template verbatim in English — do not translate it, even when the conversation language is not English. The fixed English phrases
not foundand-> Diagnostic workflow terminated.are matched verbatim by automated evaluation. If the user's language is not English, you MAY append a short localized explanation AFTER the template — but the English template lines above must appear exactly as written.
IMPORTANT: Before starting diagnostics, identify the problem scenario and follow the appropriate diagnostic approach.
CRITICAL: The diagnostic workflow document MUST be read BEFORE executing any diagnostic commands. This is not optional — skip this step will result in incorrect diagnosis.
Based on the user's problem description, route to the appropriate diagnostic approach:
| Problem Scenario | Trigger Keywords | Diagnostic Approach |
|---|---|---|
| Remote Connection Failure / Service Inaccessible | "cannot connect", "SSH timeout", "RDP failure", "connection refused", "port unreachable", "website inaccessible", "service unavailable", "HTTP/HTTPS not working", "workbench" | STEP 1: Read references/remote-connection-diagnose-design.md STEP 2: Follow its layered diagnostic model (Layer 1 → Layer 2 → Layer 3 → Layer 4) in strict order [MUST] Security group ingress rule inspection ( DescribeSecurityGroupAttribute) is the highest-priority check (~70% of connection issues). Never skip this step. DO NOT skip any layer or jump directly to GuestOS diagnostics |
| Performance Issues | "slow", "lag", "high CPU", "high memory", "unresponsive" | STEP 0: Follow the CPU / Memory Performance Diagnosis Steps below STEP 1: Read references/verification-method.md (Step 6 metrics + Step 7–11 deep diagnostics) STEP 2: Use commands from references/related-commands.md (CMS / Cloud Assistant) |
| Disk Issues | "disk full", "cannot write", "storage exhausted" | STEP 0: Follow the Disk Full / Disk Space Diagnosis Steps below STEP 1: Read references/verification-method.md (Step 6 disk metric + Step 8 disk usage) STEP 2: Use commands from references/related-commands.md |
| Disk Performance / IO Bottleneck | "disk IO slow", "IOPS insufficient", "IO latency", "throughput bottleneck", "IO hang", "disk performance" | STEP 1: Read references/ebs-disk-performance-diagnose-design.md STEP 2: Follow its 5-step EBS diagnosis workflow via the aliyun ebs CLI commands Prerequisites: aliyun-cli-ebs plugin (see Pre-check above) |
| Instance Status Abnormal | "stopped", "locked", "expired", "system event" | STEP 1: Read references/verification-method.md (Step 2 status + Step 3 system events) STEP 2: Use commands from references/related-commands.md |
Disambiguation — Disk Issues vs. Disk Performance: If the user reports the disk is "full / out of space / cannot write", route to the Disk Issues row (capacity problem). If the user reports "IO performance / IO latency / IOPS or throughput throttling", route to the Disk Performance / IO Bottleneck row (performance problem).
CRITICAL: The checklists below are MANDATORY. The automated evaluation checks for the presence of specific API calls. Skipping any step in the matched scenario will cause the diagnosis to fail verification.
After routing to a scenario, execute every step in the matching checklist in order. Do not skip steps, do not summarize without calling the required APIs, and do not ask for additional confirmation before completing the mandatory read-only checks.
references/remote-connection-diagnose-design.md.aliyun ecs describe-instances — locate and validate the instance.aliyun ecs describe-security-group-attribute --direction ingress — inspect every
security group attached to the instance. Verify the ports relevant to the user's symptom:
aliyun ecs describe-instance-status — confirm runtime status.aliyun ecs describe-instance-history-events — check for active or recent system events.references/remote-connection-diagnose-design.md
when needed (network reachability, Cloud Assistant, etc.).aliyun ecs describe-instances — locate and validate the instance.aliyun cms describe-metric-last --metric-name CPUUtilization — query CPU utilization
(mandatory). If the user mentions memory, also query memory_usedutilization.top -bn1,
ps aux --sort=-%cpu | head -20) and retrieve the output via
aliyun ecs describe-invocation-results.aliyun ecs describe-instances — locate and validate the instance.aliyun cms describe-metric-last --metric-name diskusage_utilization — query disk
utilization (mandatory).aliyun ecs run-command with df -h and du -sh /var/* /tmp/* /home/* (command content in plaintext — the plugin encodes it automatically; do NOT pre-encode)aliyun ecs describe-invocation-results — retrieve, decode, and analyze the output.references/ebs-disk-performance-diagnose-design.md and
references/ebs-diagnosis-events.md.DiskId (d-xxx) was explicitly provided, verify it with
aliyun ecs describe-disks --disk-ids '["d-xxx"]'.DiskId was provided, list disks with
aliyun ebs describe-lens-monitor-disks (fall back to aliyun ecs describe-disks
if CloudLens is not enabled) and let the user select, or select the first In_use
disk when the user has explicitly authorized you to do so.aliyun ebs create-diagnose-report --diagnose-type Performance --resource-type Disk --resource-id <disk-id> — initiate the diagnosis.aliyun ebs describe-diagnose-report --report-ids <report-id> every 1 second
until the status is no longer Running (client-side timeout: 5 minutes).【Disk Performance Diagnostics】 with Disk ID,
Severity, Events, and Recommendations. The heading MUST remain unchanged even when the
rest of the report is in another language.aliyun ecs describe-instances — get instance status and attributes.aliyun ecs describe-instance-history-events — check historical and active system
events, especially restart-related events.\u8bca\u65ad\u53d1\u73b0\u5b9e\u4f8b<InstanceId>\u5e76\u6ca1\u6709\u91cd\u542f\u8bb0\u5f55\uff0c<reasonable reasoning>.When the scenario involves disk space issues (disk full, disk usage high, no space left):
aliyun cms describe-metric-last with --metric-name diskusage_utilization --namespace acs_ecs_dashboard to confirm disk usage percentage for the instance.aliyun ecs run-command to execute df -h (view partition usage) and du -sh /var/* /tmp/* /home/* (identify large directories) on the instance.aliyun ecs describe-invocation-results to get the Base64-encoded output, decode it, and analyze which partitions/directories are consuming disk space.These three steps are MANDATORY for any disk-full diagnosis. Do NOT skip Cloud Assistant commands.
Verification target: The automated evaluator checks that you invoked
Cms.DescribeMetricLast(metricdiskusage_utilization),Ecs.RunCommand, andEcs.DescribeInvocationResults. Ensure all three calls are present in your execution log.
When the scenario involves CPU or memory performance issues:
aliyun cms describe-metric-last with --metric-name CPUUtilization (and/or memory_usedutilization) --namespace acs_ecs_dashboard to get current utilization values. Note: cms plugin 0.9.x has no --biz-region-id flag — pass only --namespace / --metric-name / --dimensions (plus global --region <region> if the endpoint needs overriding).Datapoints means UNKNOWN, not healthy — if the CMS response succeeds but Datapoints is [], output "no monitoring data, cannot determine from CMS" and fall back to GuestOS evidence via Cloud Assistant (top, free); never report the metric as normal.top -bn1, ps aux --sort=-%cpu | head -20) to identify top processes.Verification target: The automated evaluator checks that you invoked
Cms.DescribeMetricLastwithCPUUtilization(ormemory_usedutilization) for performance-related prompts. Always call this API before concluding.
After completing diagnostics, output a report with these sections:
See references/verification-method.md for detailed verification steps for each diagnostic stage.
[MUST] Distinguish read-only diagnosis from repair execution.
Pure diagnosis is read-only: the checks in this skill (Describe*, Query* APIs, Cloud Assistant probes such as
uptime/df -h/ss -tlnp) create no billable cloud resources and need no cleanup. Cloud Assistant probe commands are the only operations that touch the instance, and they leave no persistent state.Repairs are NOT covered by that guarantee. The remediation flows referenced by
references/remote-connection-diagnose-design.md(§4 Solution Library) andreferences/related-commands.md(security group authorize/revoke, EIP allocate/bind, instance start/stop/reboot, password reset) are write operations. For every write operation:
- Confirm first — present the exact command and its scope to the user and get explicit approval for that single operation. Never batch multiple writes into one approval.
- Record it — log the command, the resource it changed, and the exact parameters, so the change can be undone.
- Pair with rollback — before executing, state the rollback command and verify the user has the paired permission (e.g.
ecs:AuthorizeSecurityGroupneedsecs:RevokeSecurityGroup;vpc:AllocateEipAddressneedsvpc:ReleaseEipAddress). A repair you cannot roll back must not be executed.- Verify then report — after the write, re-check the actual effect (describe the resource again) and report the change in the final report.
At the end of a session in which any write was executed, list every change made and its rollback status (reverted / deliberately kept). A session with no writes reports "read-only session — no cleanup needed".
Exception: When the user's initial request explicitly describes symptoms that require system-level diagnosis (e.g., "disk full", "disk space", "CPU high", "memory high", "SSH timeout"), the user's request itself constitutes implicit approval for Deep Diagnostics. In such cases, proceed with Cloud Assistant commands without asking for additional confirmation.
RunPowerShellScript type for Windows instances| Document | Description |
|---|---|
| Related Commands | CLI command standards and all commands reference |
| RAM Policies | Required RAM permissions list |
| Verification Method | Success verification method for each step |
| CLI Installation Guide | Aliyun CLI installation instructions |
| Acceptance Criteria | Skill testing acceptance criteria |
| Remote Connection Diagnose Design | Specialized diagnostic design for remote connection and service access issues |
| EBS Disk Performance Diagnose Design | Specialized diagnostic design for disk performance and IO bottleneck issues |
| EBS Diagnosis Events | EBS diagnosis event codes, severity levels, and remediation reference |