MCPcopy Index your code
hub / github.com/cprobe/catpaw

github.com/cprobe/catpaw @v0.24.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.24.0 ↗ · + Follow
2,653 symbols 9,740 edges 282 files 498 documented · 19% updated 3mo agov0.24.0 · 2026-03-22★ 2445 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

English | 中文

🐾 catpaw

catpaw 是一个轻量的监控 Agent,具备 AI 智能诊断能力。 它通过插件化检查探测异常、产出标准事件,并在告警触发时自动调用 AI 进行根因分析——内置 70+ 诊断工具,覆盖系统、网络、存储、安全等各个维度。

事件可推送到任意告警平台(Flashduty、PagerDuty 或任何 HTTP 端点),也可直接输出到控制台快速验证。

✨ 核心特点

  • 🪶 轻量无重依赖 — 单二进制,部署简单
  • 🔌 插件化监控 — 25+ 检查插件,按需启用
  • 🤖 AI 自动诊断 — 告警触发后自动分析根因
  • 💬 AI 交互排障 — 命令行对话式排障,AI + 工具联动
  • 🩺 主动健康巡检 — 按需对目标执行 AI 驱动的深度检查
  • 🛠️ 70+ 诊断工具 — 系统、网络、存储、安全、进程、内核全覆盖
  • 📡 灵活通知 — 控制台、通用 WebAPI、Flashduty、PagerDuty,可同时开启多个
  • 🔄 适合自监控 — 监控系统的监控系统,避免循环依赖

🏗️ 架构概览

┌─────────────────────────────────────────────────────────────────┐
│                        catpaw agent                             │
│                                                                 │
│  ┌─────────────┐   告警    ┌──────────────┐    AI + 工具       │
│  │  25+ 检查   │ ────────── │  AI 诊断    │ ──────────────┐   │
│  │    插件     │   触发     │    引擎     │               │   │
│  └──────┬──────┘            └──────────────┘               │   │
│         │                                                  ▼   │
│         │ 事件      ┌──────────────┐         ┌───────────────┐ │
│         └────────── │   通知渠道   │         │  70+ 诊断    │ │
│                     │  (多选)    │         │     工具     │ │
│                     └──────────────┘         └───────────────┘ │
│                                                                 │
│  ┌─────────────┐                                                │
│  │  AI Chat    │ ───── 交互式排障                               │
│  │  (命令行)   │                                                │
│  └─────────────┘                                                │
└─────────────────────────────────────────────────────────────────┘

🔍 检查插件

插件 说明
cert TLS 证书有效期检查(远程 TLS + 本地文件,支持 STARTTLS、SNI、glob)
conntrack 连接跟踪表使用率监控,预防表满导致静默丢包(Linux)
cpu CPU 使用率、归一化每核 Load Average 检查
disk 磁盘空间、inode、可写性检查
dns DNS 解析检查
docker Docker 容器监控(运行状态、频繁重启、健康检查、CPU/内存)
exec 执行脚本/命令产生事件(支持 JSON 和 Nagios 模式)
filecheck 文件存在性、mtime、checksum 检查
filefd 系统级文件描述符使用率监控(Linux)
http HTTP 可用性、状态码、响应体、证书过期检查
journaltail journalctl 增量日志读取 + 关键词匹配(Linux)
logfile 日志文件监控(偏移量追踪 + 轮转检测 + glob + 多编码)
mem 内存、Swap 使用率检查
mount 挂载点基线检查(文件系统类型、挂载选项合规,Linux)
neigh ARP/邻居表使用率监控,预防新 IP 通信失败(K8s 重灾区)
net TCP/UDP 连通性与响应时间检查
netif 网卡健康检查(链路状态、错误/丢包增量,Linux)
ntp NTP 同步状态、时钟偏移、时间源层级检查(Linux)
ping ICMP 可达性、丢包率、时延检查
procfd 进程级 fd 使用率监控,预防 nofile 耗尽
procnum 进程数量检查(多种查找方式)
redis Redis 监控插件,支持单机、主从和 Redis Cluster,并提供 Redis 专用 AI 诊断工具
redis_sentinel Redis Sentinel 监控插件,覆盖 quorum、master 可解析性和 Sentinel 专用 AI 诊断工具
scriptfilter 脚本输出行过滤匹配告警
secmod SELinux/AppArmor 基线检查(Linux)
sockstat TCP listen 队列溢出检测(Linux)
sysctl 内核参数基线检查,防止重启后静默重置(Linux)
systemd systemd 服务状态检查(Linux)
tcpstate TCP 连接状态监控(CLOSE_WAIT/TIME_WAIT,Netlink 采集,Linux)
uptime 系统异常重启检测
zombie 僵尸进程检测

🧠 AI 诊断工具(70+)

AI 诊断被触发时(告警、巡检或 Chat),AI Agent 可调用以下工具深入排查:

⚙️ 系统与进程:CPU Top、内存分布、OOM 历史、cgroup 限制/用量、进程线程(含 wchan)、打开文件列表、环境变量、PSI 压力指标

🌐 网络:ping、traceroute、DNS 解析、ARP 邻居表、TCP 连接状态、Socket 详情(RTT/cwnd)、重传率、连接延迟分布、Listen 队列溢出、TCP 内核调优检查、softnet 统计、路由表、IP 地址、网卡流量、防火墙规则

💾 存储:磁盘 I/O 延迟、块设备拓扑树、LVM 状态、挂载信息

🔐 内核与安全:dmesg 内核日志、中断分布、conntrack 统计、NUMA 内存分布、热区温度、sysctl 快照、SELinux/AppArmor 状态、coredump 列表

📜 日志:日志尾部读取、日志 grep(模式匹配)、journald 查询

🐳 服务:systemd 服务状态、失败服务列表、定时器列表、Docker ps/inspect

🔌 远程插件(如 Redis、Redis Sentinel)会注册专用诊断工具,用于对目标实例进行深入检查。

Redis 插件的检查项、集群语义和诊断工具见 plugins/redis/README.md。 Redis Sentinel 插件的检查项、诊断工具和配置语义见 plugins/redis_sentinel/README.md

🖥️ 命令行

catpaw run [flags]                      # 启动监控 Agent
catpaw chat [-v]                        # AI 交互式排障
catpaw inspect <plugin> [target]        # AI 主动健康巡检
catpaw diagnose list|show <id>          # 查看历史诊断记录
catpaw selftest [filter] [-q]           # 诊断工具自检

🚀 快速开始

📦 安装

GitHub Releases 下载对应平台的二进制。

基础监控

  1. conf.d/p.<plugin>/ 下启用需要的插件配置
  2. 启动:
./catpaw run

默认配置已开启 [notify.console],事件会以带颜色的格式输出到终端——无需任何外部服务即可快速验证。

📡 事件通知

catpaw 支持多种通知渠道,在 conf.d/config.toml 中配置,可同时启用多个:

渠道 配置段 说明
控制台 [notify.console] 输出到终端(默认开启)
通用 WebAPI [notify.webapi] 将原始 Event JSON 推送到任意 HTTP 端点
Flashduty [notify.flashduty] 对接 Flashduty 告警平台
PagerDuty [notify.pagerduty] 对接 PagerDuty 事件管理平台

控制台(默认开启,快速验证):

[notify.console]
enabled = true

通用 WebAPI(推送原始 Event JSON 到任意 HTTP 端点):

[notify.webapi]
url = "https://your-service.example.com/api/v1/events"
# method = "POST"
# timeout = "10s"
[notify.webapi.headers]
Authorization = "Bearer ${WEBAPI_TOKEN}"

Flashduty

[notify.flashduty]
integration_key = "your-integration-key"

PagerDuty

[notify.pagerduty]
routing_key = "your-routing-key"

🤖 AI 智能诊断(可选)

conf.d/config.toml 中添加:

[ai]
enabled = true
model_priority = ["default"]

[ai.models.default]
base_url = "https://api.openai.com/v1"
api_key = "${OPENAI_API_KEY}"
model = "gpt-4o"

配置后,告警触发时 AI 会自动调用内置诊断工具分析根因。

💬 交互式 Chat

./catpaw chat

直接提问,如"CPU 为什么高?"、"检查磁盘 I/O"等,AI 会使用诊断工具和 Shell 命令(需用户确认)进行排查。

⚙️ 配置说明

  • 全局配置:conf.d/config.toml
  • 本地覆盖:conf.d/config.local.toml(最后加载,已加入 git ignore,适合开发者本地调试)
  • 插件配置:conf.d/p.<plugin>/*.toml(每个目录可放多个 .toml 文件,合并加载)
  • 顶层加载顺序:config.toml -> conf.d/ 中其他文件 -> config.local.toml
  • 支持 SIGHUP 热加载插件配置:
kill -HUP $(pidof catpaw)

📚 详细文档

文档 说明
开发必读 架构全貌与代码导航 — 新人请先读这篇
部署指南 二进制部署、systemd 服务、Docker 部署
事件数据模型 Event 结构、Labels 设计、AlertKey 规则、告警生命周期
插件开发指南 如何新增一个 catpaw 插件

💬 交流

可加微信 picobyte 进群交流,备注 catpaw

Extension points exported contracts — how you extend this code

Gatherer (Interface)
(no doc) [33 implementers]
digcore/plugins/interface.go
ChatClient (Interface)
ChatClient is the interface for AI chat backends (OpenAI, Bedrock, etc.). [3 implementers]
digcore/diagnose/aiclient/types.go
Filter (Interface)
(no doc) [5 implementers]
digcore/pkg/filter/filter.go
Notifier (Interface)
(no doc) [5 implementers]
digcore/notify/notify.go
ChatHandle (Interface)
ChatHandle is a handle to an active chat session. [2 implementers]
digcore/server/session.go
Initer (Interface)
(no doc) [33 implementers]
digcore/plugins/interface.go
ShellExecutor (Interface)
ShellExecutor is an interface for executing shell commands during chat. Implementations must handle user approval and co [2 …
digcore/diagnose/streaming.go
CommentNotifier (Interface)
(no doc) [2 implementers]
digcore/notify/notify.go

Core symbols most depended-on inside this repo

SetDescription
called by 373
digcore/types/event.go
PushFront
called by 336
digcore/pkg/safe/queue.go
SetEventStatus
called by 277
digcore/types/event.go
String
called by 239
plugins/journaltail/journaltail.go
Error
called by 206
digcore/mcp/types.go
NewQueue
called by 138
digcore/pkg/safe/queue.go
Len
called by 132
digcore/pkg/safe/queue.go
SetAttrs
called by 124
digcore/types/event.go

Shape

Function 1,619
Method 606
Struct 390
Interface 20
FuncType 9
TypeAlias 9

Languages

Go100%

Modules by API surface

plugins/tcpstate/tcpstate_test.go45 symbols
plugins/redis/redis_test.go41 symbols
plugins/cert/cert_test.go39 symbols
digcore/plugins/interface.go36 symbols
plugins/mount/mount_test.go35 symbols
plugins/redis/accessor.go34 symbols
plugins/netif/netif_test.go34 symbols
plugins/redis_sentinel/accessor.go33 symbols
digcore/config/config.go33 symbols
plugins/logfile/logfile_test.go31 symbols
plugins/docker/docker.go31 symbols
digcore/diagnose/registry.go30 symbols

For agents

$ claude mcp add catpaw \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact