with one click
sosreport-analyzer
一种 Linux 系统诊断和分析工具,收集系统配置、日志、性能数据并生成诊断报告
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
一种 Linux 系统诊断和分析工具,收集系统配置、日志、性能数据并生成诊断报告
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
深度系统辅助工具集 - 系统监控、体检、日志分析和基线配置管理(兼容多种 Linux 发行版)
Docker containerization expert specializing in multi-stage builds, image optimization, Docker Compose patterns, and production container security. Use for Dockerfile optimization, compose configurations, and container best practices.
Platform engineering expert specializing in internal developer platforms, self-service infrastructure, Backstage service catalogs, GitOps with ArgoCD, and golden path templates. Use for building developer portals and platform-as-a-product.
系统卡顿诊断专家 - 检测 CPU/内存/Swap/磁盘瓶颈,分析原因并给出安全的进程关闭建议(适用于 Debian/Deepin 系统)
Create new skills from documents, tutorials, or examples. Use when user wants to create a skill from learning materials or existing content.
Design and customize prompts for aish shell. Use when user wants to modify their shell prompt, describe desired prompt style, or switch between prompt themes. Triggers on keywords like "prompt", "提示符", "主题".
| name | sosreport-analyzer |
| version | 1.0.0 |
| description | 一种 Linux 系统诊断和分析工具,收集系统配置、日志、性能数据并生成诊断报告 |
| author | deepin |
| triggers | ["sosreport","system diagnostic","系统诊断","收集日志","troubleshooting","故障排查","system info","系统信息收集"] |
| platforms | ["linux"] |
| distributions | ["debian","ubuntu","rhel","centos","fedora","rocky","alma"] |
自动收集 Linux 系统的配置、日志、性能数据,并进行智能分析和问题诊断。
核心能力:
用户: 生产服务器响应缓慢,帮我做个系统诊断
助手: 我将使用 sosreport-analyzer 收集系统数据...
[执行数据收集]
[分析报告]
发现问题:
1. CPU iowait 高达 45%,磁盘 /dev/sda 存在性能瓶颈
2. 内存使用 92%,swap 频繁使用
3. systemd-journald 服务占用 2GB 日志空间
用户: 定期巡检,生成系统健康报告
助手: 正在收集系统状态...
[生成 HTML/Markdown 报告]
用户: 准备将 deepin 迁移到 UOS,先做个系统扫描
助手: 扫描兼容性问题...
[检测内核模块、配置文件、软件包兼容性]
收集内容:
# 发行版信息
- /etc/os-release
- lsb_release -a
- uname -a
# 硬件信息
- lscpu (CPU 架构、核心数、NUMA 拓扑)
- lsmem (内存配置、分布)
- dmidecode (BIOS、主板、硬件序列号)
- lspci (PCI 设备)
- lsusb (USB 设备)
- lsblk (块设备)
# 虚拟化检测
- systemd-detect-virt
- virt-what
分析重点:
收集内容:
# 内核信息
- uname -r
- cat /proc/cmdline
- cat /proc/version
- lsmod (已加载模块)
- dmesg (启动日志)
# 启动配置
- /boot/grub*/grub.cfg
- /etc/default/grub
- systemctl list-jobs
- systemd-analyze blame (启动时间分析)
分析重点:
收集内容:
# Systemd Journal
- journalctl --no-pager --since "7 days ago" -p err
- journalctl --disk-usage
- journalctl -u <critical-services> --since "24 hours ago"
# 传统日志(如果存在)
- /var/log/messages (RHEL)
- /var/log/syslog (Debian/Ubuntu)
- /var/log/auth.log
- /var/log/secure
- /var/log/audit/audit.log
# 应用日志
- /var/log/nginx/
- /var/log/apache2/
- /var/log/mysql/
智能分析:
收集内容:
# 网络接口
- ip addr show
- ip link show
- ip route show
- ip -s link (流量统计)
# 网络连接
- ss -tunap (所有连接)
- netstat -i (接口统计)
- arp -n
# DNS 配置
- cat /etc/resolv.conf
- cat /etc/hosts
- cat /etc/nsswitch.conf
# 防火墙
- iptables -L -n -v (如果使用)
- nft list ruleset (nftables)
- firewall-cmd --list-all (firewalld)
- ufw status verbose (Ubuntu)
# 网络服务
- systemctl status NetworkManager
- nmcli connection show
诊断检查:
收集内容:
# 磁盘信息
- lsblk -f
- fdisk -l
- parted -l
- blkid
# 文件系统
- df -h
- df -i (inode 使用率)
- mount
# LVM (如果使用)
- pvs, vgs, lvs
- pvdisplay, vgdisplay, lvdisplay
# RAID (如果使用)
- cat /proc/mdstat
- mdadm --detail /dev/md*
# 磁盘健康
- smartctl -a /dev/sda (需要 smartmontools)
# I/O 性能
- iostat -x 1 5
- iotop -b -n 3 (需要 root)
风险检测:
收集内容:
# 内存状态
- free -h
- cat /proc/meminfo
- slabtop -o (内核 slab 缓存)
- vmstat 1 5
# CPU 性能
- top -b -n 3
- mpstat -P ALL 1 3
- uptime
# 进程信息
- ps aux --sort=-%mem | head -20
- ps aux --sort=-%cpu | head -20
- pstree -p
# Swap 使用
- swapon -s
- cat /proc/swaps
性能分析:
收集内容:
# Systemd 服务
- systemctl list-units --type=service --all
- systemctl --failed
- systemctl list-timers
# 关键服务状态
- systemctl status sshd
- systemctl status NetworkManager
- systemctl status firewalld
# 进程树
- pstree -a
- ps -eo pid,ppid,cmd,stat,start
健康检查:
收集内容:
# SELinux (RHEL/CentOS)
- getenforce
- sestatus
- ausearch -m AVC -ts recent (AVС 拒绝日志)
# AppArmor (Debian/Ubuntu)
- aa-status
- aa-enabled
# 审计系统
- auditctl -l
- aureport --summary
# 登录记录
- last -20
- lastb -20 (失败登录)
- who
- w
# SSH 配置
- cat /etc/ssh/sshd_config (敏感项模糊化)
# 用户与权限
- cat /etc/passwd
- cat /etc/group
- find / -perm -4000 -type f 2>/dev/null (SUID 文件)
安全审计:
收集内容:
# RHEL/CentOS/Fedora
- rpm -qa
- dnf repolist
- dnf history
- dnf check
# Debian/Ubuntu
- dpkg -l
- apt list --installed
- apt-cache policy
# 内核包
- rpm -qa | grep kernel (RHEL)
- dpkg -l | grep linux-image (Debian)
检查项:
可扩展模块:
# 数据库
- MySQL/PostgreSQL 配置和状态
- 数据库连接数、慢查询
# Web 服务器
- Nginx/Apache 配置检查
- 访问日志统计
# 容器
- docker info
- docker ps -a
- podman info
# 监控代理
- Prometheus node_exporter 指标
- Zabbix agent 状态
- rule: high_cpu_iowait
condition: iowait > 30%
severity: HIGH
message: "CPU iowait 过高,可能存在磁盘 I/O 瓶颈"
suggestions:
- "检查 iostat 输出,定位慢速磁盘"
- "使用 iotop 识别 I/O 密集型进程"
- "考虑使用 SSD 或优化文件系统参数"
- rule: memory_pressure
condition: available_memory < 10% AND swap_used > 50%
severity: CRITICAL
message: "内存压力严重,系统频繁使用 swap"
suggestions:
- "识别内存泄漏进程并重启"
- "增加物理内存"
- "调整 vm.swappiness 参数"
- rule: disk_space_critical
condition: disk_usage > 95%
severity: CRITICAL
message: "磁盘空间严重不足"
suggestions:
- "清理日志文件:journalctl --vacuum-time=7d"
- "删除旧内核:dnf remove --oldinstallonly"
- "扩展文件系统或添加新磁盘"
- rule: failed_services
condition: systemctl --failed count > 0
severity: MEDIUM
message: "存在失败的 systemd 服务"
suggestions:
- "使用 journalctl -u <service> 查看失败原因"
- "检查服务依赖关系"
- rule: zombie_processes
condition: zombie_count > 5
severity: LOW
message: "检测到僵尸进程"
suggestions:
- "识别父进程并修复其信号处理逻辑"
- "必要时重启父进程"
- rule: packet_drops
condition: rx_dropped > 1% OR tx_dropped > 1%
severity: MEDIUM
message: "网络接口丢包严重"
suggestions:
- "检查网卡驱动版本"
- "增加 ring buffer: ethtool -G eth0 rx 4096"
- "调整 net.core.netdev_max_backlog"
- rule: selinux_disabled
condition: selinux_status == "disabled"
severity: HIGH
message: "SELinux 已禁用,系统安全性降低"
suggestions:
- "编辑 /etc/selinux/config 启用 SELinux"
- "需要重启系统生效"
- rule: ssh_root_login
condition: sshd_config contains "PermitRootLogin yes"
severity: MEDIUM
message: "允许 root 直接 SSH 登录存在安全风险"
suggestions:
- "修改 /etc/ssh/sshd_config: PermitRootLogin no"
- "重启 sshd: systemctl restart sshd"
═══════════════════════════════════════════════════
系统诊断报告 - SOS Report Analyzer v1.0
═══════════════════════════════════════════════════
📌 系统信息
OS: Ubuntu 22.04.3 LTS
Kernel: 5.15.0-91-generic
Platform: VMware Virtual Platform
Uptime: 45 days, 3:12:34
⚠️ 检测到 3 个问题
[CRITICAL] 磁盘空间严重不足
/dev/sda1 使用率: 97% (仅剩 1.2GB)
→ 建议: journalctl --vacuum-time=7d
[HIGH] CPU iowait 过高
当前 iowait: 42%
→ 建议: 检查 /dev/sda 性能,考虑迁移到 SSD
[MEDIUM] 存在 2 个失败的服务
- systemd-networkd.service
- docker.service
→ 建议: journalctl -u systemd-networkd
✅ 健康检查
[✓] 内存使用正常 (62%)
[✓] 网络接口无丢包
[✓] SELinux 状态正常
[✓] 无僵尸进程
📊 完整报告已保存到:
/tmp/sosreport-20260105-143022.tar.gz
# 系统诊断报告
**生成时间:** 2026-01-05 14:30:22
**主机名:** prod-web-01
**报告版本:** sosreport-analyzer v1.0
## 执行摘要
本次诊断发现 **3 个关键问题** 和 **5 个优化建议**。
### 严重问题
1. ❌ 磁盘空间不足(/dev/sda1 97%)
2. ⚠️ CPU iowait 异常(42%)
3. ⚠️ 2 个服务失败
### 系统概览
- **操作系统:** Ubuntu 22.04.3 LTS (Jammy Jellyfish)
- **内核:** 5.15.0-91-generic
- **CPU:** Intel Xeon E5-2680 v4 @ 2.40GHz (8 cores)
- **内存:** 16GB (使用 62%)
- **运行时间:** 45 天
[详细章节...]
{
"metadata": {
"version": "1.0.0",
"timestamp": "2026-01-05T14:30:22Z",
"hostname": "prod-web-01",
"collector": "sosreport-analyzer"
},
"system": {
"os": {
"distribution": "Ubuntu",
"version": "22.04.3 LTS",
"codename": "Jammy Jellyfish"
},
"kernel": "5.15.0-91-generic",
"hardware": {
"cpu": {
"model": "Intel Xeon E5-2680 v4",
"cores": 8,
"threads": 16
},
"memory": {
"total_gb": 16,
"used_percent": 62
}
}
},
"issues": [
{
"severity": "CRITICAL",
"category": "storage",
"title": "Disk space critical",
"details": "/dev/sda1 usage: 97%",
"recommendations": [
"journalctl --vacuum-time=7d",
"Clean old kernels",
"Expand filesystem"
]
}
],
"health_checks": {
"memory": "PASS",
"network": "PASS",
"services": "WARN",
"security": "PASS"
}
}
# 在 Claude Code 中触发
帮我做个系统诊断
运行 sosreport 收集系统信息
系统健康检查
# 指定收集模块
只收集网络和存储信息
# 深度分析模式
做个完整的系统诊断,包括性能分析
# 导出特定格式
生成 JSON 格式的诊断报告
# 创建 cron 任务(需要用户确认)
每周一早上 8 点自动生成系统报告
systemctl (systemd)journalctl (日志)ip / ss (网络)df / lsblk (存储)top / ps (进程)iostat / iotop (I/O 分析) - sysstat 包smartctl (磁盘健康) - smartmontools 包dmidecode (硬件信息) - 需要 rootauditctl (审计) - auditd 包docker / podman (容器信息)如果缺少可选工具,skill 会:
自动模糊化敏感信息:
/tmp/sosreport-<timestamp>.tar.gz在 scripts/custom/ 目录下添加脚本:
# scripts/custom/collect_mysql.sh
#!/bin/bash
# 收集 MySQL 状态
if command -v mysql &>/dev/null; then
mysql -e "SHOW STATUS" > mysql_status.txt
mysql -e "SHOW VARIABLES" > mysql_variables.txt
fi
编辑 templates/rules.yaml 添加检测规则。
# 检查磁盘空间
df -h /tmp
# 检查权限
ls -ld /tmp
# 手动运行收集脚本
bash ~/.claude/skills/sosreport-analyzer/scripts/collect_all.sh
# 检查缺失的工具
~/.claude/skills/sosreport-analyzer/scripts/check_dependencies.sh
# 安装推荐工具(Debian/Ubuntu)
sudo apt install sysstat smartmontools
# 安装推荐工具(RHEL/CentOS)
sudo dnf install sysstat smartmontools
版本历史: