📦 Pilot — 飞行员
v1.0.0Fleet Health Monitor Setup 部署一个包含 3 个代理的舰队健康监控系统。 在以下场景使用此技能: 1. 用户希望设置舰队或服务器健康监控 2. 用户正在配置...
详细分析 ▾
运行时依赖
版本
初始版本
安装命令
点击复制技能文档
部署 3 个监控服务器健康并聚合告警的 agent。
角色
| 角色 | 主机名 | 技能 | 用途 | |-------------|-------------------------|----------------------------------------------------------------------|-------------------------------| | web-monitor |-web-monitor | pilot-health, pilot-alert, pilot-metrics | 监控 Web 服务器,发布健康告警 |
| db-monitor | -db-monitor | pilot-health, pilot-alert, pilot-metrics | 监控数据库,发布健康告警 |
| alert-hub | -alert-hub | pilot-webhook-bridge, pilot-alert, pilot-event-filter, pilot-slack-bridge | 聚合告警,转发给人类 | 部署流程
步骤 1: 询问用户该 agent 的角色及前缀。 步骤 2: 为选定角色安装技能: ``bash
# web-monitor 或 db-monitor:
clawhub install pilot-health pilot-alert pilot-metrics # alert-hub:
clawhub install pilot-webhook-bridge pilot-alert pilot-event-filter pilot-slack-bridge
`
步骤 3: 设置主机名:
`bash
pilotctl --json set-hostname -
`
步骤 4: 写入部署清单:
`bash
mkdir -p ~/.pilot/setups
cat > ~/.pilot/setups/fleet-health-monitor.json << 'MANIFEST'
{
"setup": "fleet-health-monitor",
"setup_name": "Fleet Health Monitor",
"role": "",
"role_name": "",
"hostname": "-",
"description": "",
"skills": {
"": ""
},
"peers": [
{
"role": "...",
"hostname": "...",
"description": "..."
}
],
"data_flows": [
{
"direction": "send|receive",
"peer": "...",
"port": 1002,
"topic": "...",
"description": "..."
}
],
"handshakes_needed": [
""
]
}
MANIFEST
`
步骤 5: 告知用户与直连 peer 完成 handshake。
各角色清单模板
web-monitor
`json
{
"setup": "fleet-health-monitor",
"setup_name": "Fleet Health Monitor",
"role": "web-monitor",
"role_name": "Web Server Monitor",
"hostname": "-web-monitor",
"description": "监控 nginx/应用健康、CPU、内存、响应时间;阈值越限时发出告警事件。",
"skills": {
"pilot-health": "按计划或按需检查 nginx、应用端点、SSL 证书。",
"pilot-alert": "健康检查失败时,向 -alert-hub 发布 health-alert 主题告警。",
"pilot-metrics": "采集 CPU、内存、磁盘、响应时间,格式化为 JSON 事件载荷。"
},
"peers": [
{
"role": "db-monitor",
"hostname": "-db-monitor",
"description": "同组监控,无直接通信"
},
{
"role": "alert-hub",
"hostname": "-alert-hub",
"description": "中心告警聚合器,接收 health-alert 事件"
}
],
"data_flows": [
{
"direction": "send",
"peer": "-alert-hub",
"port": 1002,
"topic": "health-alert",
"description": "健康检查失败与指标异常"
}
],
"handshakes_needed": ["-alert-hub"]
}
` db-monitor
`json
{
"setup": "fleet-health-monitor",
"setup_name": "Fleet Health Monitor",
"role": "db-monitor",
"role_name": "Database Monitor",
"hostname": "-db-monitor",
"description": "监控数据库连接、查询延迟、复制滞后、磁盘用量;异常时发出告警。",
"skills": {
"pilot-health": "检查 PostgreSQL/MySQL 连接、复制滞后、磁盘用量。",
"pilot-alert": "数据库健康失败时,向 -alert-hub 发布 health-alert 主题告警。",
"pilot-metrics": "采集查询延迟、连接池统计、表大小。"
},
"peers": [
{
"role": "web-monitor",
"hostname": "-web-monitor",
"description": "同组监控,无直接通信"
},
{
"role": "alert-hub",
"hostname": "-alert-hub",
"description": "中心告警聚合器,接收 health-alert 事件"
}
],
"data_flows": [
{
"direction": "send",
"peer": "-alert-hub",
"port": 1002,
"topic": "health-alert",
"description": "数据库告警与复制警告"
}
],
"handshakes_needed": ["-alert-hub"]
}
``