com um clique
linux
CPU、内存、磁盘、网络性能排查的系统化流程,覆盖 top/vmstat/iostat/ss/strace 等工具
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
CPU、内存、磁盘、网络性能排查的系统化流程,覆盖 top/vmstat/iostat/ss/strace 等工具
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
生成或审计模块的 SPEC.md。使用场景:用户要求"给 XX 模块写 spec"、"审计所有 spec"、"检查 spec 是否过期"。
Automates SailFish release workflow: fix build/type errors, update CHANGELOG (EN + CN), run npm version with pre/post hooks. Use when the user asks to release, 发版, 发布, bump version, or update changelog.
后端代码修改后,通过 CLI 测试验证功能正确性。使用场景:修改了 electron/services/ 下的代码需要测试、准备提交代码前跑回归、用户要求"跑测试"/"验证一下"。
完成新功能开发或较大修改后,使用本机 Claude CLI 进行代码审查。
使用 ts-morph 静态分析工具查询代码结构(类层次、方法签名、引用、依赖等),替代手动读源码。使用场景:需要了解类的方法/属性、继承链、符号引用、文件结构、依赖关系时。
When committing or staging changes, only include files related to the current task or conversation; do not stage or commit unrelated modifications. Use when the user asks to commit, stage, 提交, or when preparing to run git add/commit.
| name | Linux 性能诊断工具箱 |
| description | CPU、内存、磁盘、网络性能排查的系统化流程,覆盖 top/vmstat/iostat/ss/strace 等工具 |
| version | 1.0.0 |
遵循 USE 方法论(Utilization 使用率 / Saturation 饱和度 / Errors 错误)系统化排查。
# 一分钟快速诊断(按顺序执行)
uptime # 负载趋势
dmesg -T | tail -20 # 内核报错(OOM、硬件)
vmstat 1 5 # CPU/内存/IO 概览
mpstat -P ALL 1 3 # 各 CPU 核使用率
iostat -xz 1 3 # 磁盘 IO
free -h # 内存
df -h # 磁盘空间
ss -s # 网络连接统计
top -bn1 | head -20 # 进程 Top
# 整体负载
uptime # load average > CPU 核数 → 过载
nproc # CPU 核数
# 实时查看
top # 按 1 查看各核,P 按 CPU 排序
htop # 更直观(需安装)
# 各核使用率
mpstat -P ALL 1 5
# 进程级 CPU(找出 CPU 大户)
pidstat 1 5
# CPU 被谁占了(采样分析)
perf top # 实时热点函数
perf record -g -p <pid> -- sleep 30 && perf report
常见原因:死循环、正则回溯、GC 风暴、锁竞争。
# 整体
free -h
# buffers/cache 不算真正占用,看 available
# 进程级内存
ps aux --sort=-%mem | head -20
pidstat -r 1 5
# 详细映射
pmap -x <pid>
cat /proc/<pid>/smaps_rollup
# OOM 历史
dmesg -T | grep -i 'oom\|kill'
journalctl -k | grep -i 'oom'
常见原因:内存泄漏、缓存未限制、JVM 堆配置不合理。
# 磁盘使用
df -h # 空间
df -i # inode 使用率
du -sh /var/* | sort -rh | head # 大目录排查
# I/O 性能
iostat -xz 1 5
# 关注:%util > 80% 表示接近饱和,await > 10ms 需关注
# 哪个进程在读写
iotop -oP # 实时 IO(需 root)
pidstat -d 1 5 # 进程 IO 统计
# 查找大文件
find / -xdev -type f -size +100M 2>/dev/null | head -20
# 已删除但未释放的文件
lsof +L1
常见原因:日志撑满磁盘、大量小文件、swap 抖动。
# 连接统计
ss -s # 连接总览
ss -tlnp # 监听端口
ss -tnp state established # 已建立连接
# 网络流量
iftop -i eth0 # 实时流量(需安装)
nethogs # 按进程看流量
# 连通性
ping -c 5 <host>
traceroute <host> # 路由跟踪
mtr <host> # 综合 ping + traceroute
curl -o /dev/null -w "time_total: %{time_total}s\n" http://<url>
# 抓包
tcpdump -i eth0 -nn port 80 -c 100
tcpdump -i eth0 host <ip> -w capture.pcap
常见原因:连接数耗尽(TIME_WAIT)、DNS 解析慢、带宽饱和。
# 打开的文件/连接
lsof -p <pid>
ls -la /proc/<pid>/fd | wc -l # 文件描述符数量
# 系统调用跟踪
strace -p <pid> -c # 统计系统调用耗时
strace -p <pid> -e trace=network -f # 跟踪网络调用
# 进程树
pstree -p <pid>
uptime + vmstat + free + df 定位瓶颈类型top / iotop / ss 找到占用最高的进程strace / perf / lsof 分析根因