SysOM 巡检(sysom-inspection)
巡检通过 sysom-osops CLI 命令 (sysom-osops inspection ecs ...)发起。始终通过 CLI 执行,不要直接调用 巡检 OpenAPI。
CLI 设置
检查 CLI 是否可用:
command -v sysom-osops
如果缺失,请安装:
curl -fsSL --connect-timeout 1000 https://sysom-prd-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/sysom_prd/skill_cli/install.sh | sudo bash
然后仅验证二进制文件:
command -v sysom-osops
如果已安装 CLI 但尚无 inspection 子命令,请先运行 sysom-osops update,然后重试。
如果命令因缺少 RAM 权限而失败,请按照 references/ram-policies.md 以附加最小权限策略。
快速开始
# Focused inspection by intent (--query)
# Run only CPU/load related items (keyword mapping)
sysom-osops inspection ecs --region cn-shenzhen --instance i-xxxxxxxx --query "cpu related inspection"
# Combined intent: memory and disk
sysom-osops inspection ecs --region cn-shenzhen --instance i-xxxxxxxx --query "memory and disk"
# Natural-language sentence: intent is extracted automatically, matching packet-loss items
sysom-osops inspection ecs --region cn-shenzhen --instance i-xxxxxxxx --query "check whether this machine has network packet loss"
# If the query matches no items, it falls back to a full inspection automatically
# Batch inspection (--scope-type batch, auto diagnosis supported)
# Inspect all specified instances -> auto root-cause diagnosis on the Top-3 most severe
# anomalous instances -> LLM summary (the rest get copy-ready deep-dive commands in the report)
sysom-osops inspection ecs --region cn-shenzhen --scope-type batch --instances i-aaa,i-bbb,i-ccc
# Region-wide inspection (--scope-type all, auto diagnosis supported)
# Auto-discover every ECS instance in the region (limit 5000) -> Top-3 anomalies auto-diagnosed
# -> LLM summary; one command for the full closed loop
sysom-osops inspection ecs --region cn-shenzhen --scope-type all
# Re-check an existing report (--report-id)
# Returns immediately without re-running (auto-generated in inspection next_steps)
sysom-osops inspection ecs --report-id inspection-82a64d9d-11c5-45b2-a81c-27fc754891e8
调用模式
- 聚焦巡检:
--query "<intent>"将关键词或提取出的意图映射到具体 - 批量:
--scope-type batch --instances i-aaa,i-bbb,...巡检所有指定实例, - 全地域:
--scope-type all自动发现该地域中的每个 ECS 实例 - 报告重放:
--report-id <reportId>直接返回现有报告,
巡检项(CPU/负载关键词映射、内存 + 磁盘等组合意图、网络丢包检查等自然语言 句子)。如果查询未匹配任何巡检项,则自动回退为 全量巡检。
自动诊断异常程度最严重的前 3 个实例,并在报告中 为其余实例列出可直接复制的深入排查命令。
(上限 5000 个),然后在一条命令中应用相同的前 3 个实例自动诊断和 LLM 汇总。
不会重新运行巡检;巡检结果会在 next_steps 中 自动输出此重放命令。
可观测性
- UA 模板(所有 SDK 请求都必须使用):
AlibabaCloud-Agent-Skills/{SKILL_NAME}/{session-id}- 此 skill 在运行时解析得到的形式:
AlibabaCloud-Agent-Skills/alibabacloud-alinux-sysom-inspection/<SKILL_SESSION_ID> - 统一的 session-id 规则:
- 每个会话(一次 CLI 执行)只生成一个 session-id,且必须
- 生成优先级:外部环境变量
SKILL_SESSION_ID(首选)→ 自动生成的 - 接受的格式:
[A-Za-z0-9][A-Za-z0-9._:-]{7,127}。 - 解析出的值会导出到进程环境变量
SKILL_SESSION_ID,以便下游调用 sysom-osopsCLI 会自动注入 UA 请求头,并遵循同一套统一的
在所有 API 调用中一致复用,包括 CLI 和 SDK 请求。
备用值 sid-<32-char hex>(uuid4 十六进制);注入的无效值会回退为 生成的 id。
保持一致。
session-id 规则。
执行流程
- 每次巡检前,CLI 都会验证 SysOM 是否激活以及相关权限(
InitialSysom、 - 每次新巡检都会调用 ROA API
POST /api/v1/inspection/createInstanceInspection,并传入 - 每种模式都会运行完整闭环:巡检(指标 + 日志)→ 对检测到的异常自动进行根因诊断
- 自动根因诊断通过
InvokeDiagnosis触发(将 - 批量模式(
--scope-type batch --instances ...)会巡检每个指定实例;全地域模式 - 报告查询使用 ROA API
GET /api/v1/inspection/getInspectionReport;CLI 会持续轮询,直到 --report-id <reportId>会跳过任务创建,直接获取现有报告;- 不使用本地阈值/事件规则配置;异常判断来自
source=skill_hub);激活和安装提示由 CLI 自行处理。
source=skill_hub;所选巡检项来自 --query 关键词/意图映射,未匹配任何巡检项的查询 会回退为全量巡检。
→ 生成由 LLM 汇总的中文报告。
__sysom_diagnosis_source=skill_hub 注入 params),并通过 GetDiagnosisResult 轮询,直到状态为 success / fail 或超时。
(--scope-type all)会自动发现该地域中的所有 ECS 实例(上限 5000 个)。两种模式 都会自动诊断异常程度最严重的前 3 个实例,并在报告中为其余实例提供可直接复制的 深入排查命令。
报告成功生成或超时。
巡检结果也会在 next_steps 中自动输出此重放命令。
服务端巡检报告。
错误处理
当 CLI 调用失败时,按错误文本(Error: <Code>: ...) 对故障分类并按如下方式处理,不要盲目重试:
- 权限(
Forbidden.RAM):说明缺少sysom:InitialSysom/ - 参数(
InvalidParameter、参数无效):找出有问题的参数 - 限流(
Throttling):告知用户请求受到限流,并建议 - 内部错误(
InternalError):如实报告临时服务故障,并 - 地域为空(
no ECS instances found):这不是错误。报告该地域
sysom:InvokeAgentCli,并引导用户查看 references/ram-policies.md 以获取最小权限策略;不要重试。
并指导用户核实实例 ID 和地域;不要将其归因于 服务。
稍后重试;不要在循环中自动重试。
建议稍后重试;不要将其归因于用户输入。
没有 ECS 实例并跳过巡检;绝不能编造报告。
可扩展性说明
- 巡检重点由
--query控制(将关键词/意图映射到具体巡检项); - 使用
--scope-type batch --instances ...进行批量巡检,使用--scope-type all巡检 - 使用
--report-id重新检查现有报告而不重新执行;重放命令会 - 本地 Python CLI(
./scripts/osops.sh inspection)仅保留作为备用方案,用于 - 备用路径的内存异常触发逻辑仍在
- 如需添加更多巡检后专项诊断操作,请复用
InvokeDiagnosis
未匹配的查询会回退为全量巡检。
整个地域(上限 5000 个实例);两者都会自动诊断异常程度最严重的前 3 个实例。
自动在巡检 next_steps 中输出。
sysom-osops 不可用的环境。
scripts/sysom_cli/inspection/command.py.
集成模式。