Files
ServerGuard/README.md
2026-03-02 14:14:40 +08:00

3.0 KiB
Raw Blame History

ServerGuard - 服务器硬件健康诊断系统

ServerGuard 是一款基于 Python 的 Linux 命令行工具用于诊断服务器硬件CPU、内存、存储、电源、显卡等的潜在故障。

功能特性

  • 硬件信息概览:收集 CPU、内存、主板、存储、显卡等详细信息
  • CPU 检测温度监控、MCE 错误检查、压力测试
  • 内存检测DIMM 信息、ECC 状态检查、内存压力测试
  • 存储检测SMART 数据分析、I/O 性能测试、RAID 状态检查
  • 传感器监控:电压、风扇转速、温度监控(支持 IPMI
  • 显卡检测GPU 信息、温度、驱动状态检查
  • 日志分析:自动扫描系统日志中的硬件错误
  • 报告生成:支持 JSON、CSV、纯文本、HTML 格式

安装

系统要求

  • Python 3.8+
  • Linux 操作系统
  • root 权限(大多数硬件诊断功能需要)

安装系统依赖

Debian/Ubuntu:

sudo apt update
sudo apt install -y lshw dmidecode smartmontools lm-sensors stress-ng memtester ipmitool edac-utils fio mdadm pciutils usbutils

CentOS/RHEL:

sudo yum install -y lshw dmidecode smartmontools lm_sensors stress-ng memtester OpenIPMI edac-utils fio mdadm pciutils usbutils

安装 Python 依赖

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

使用方法

快速检测(非侵入性)

sudo python3 main.py --quick

全面诊断(包含压力测试)

sudo python3 main.py --full

运行特定模块

sudo python3 main.py --module cpu
sudo python3 main.py --module memory
sudo python3 main.py --module storage

生成不同格式的报告

sudo python3 main.py --full --format json --output report.json
sudo python3 main.py --full --format html --output report.html

查看帮助

python3 main.py --help

项目结构

ServerGuard/
├── main.py              # 程序入口和核心调度器
├── utils.py             # 通用工具库
├── reporter.py          # 报告生成模块
├── requirements.txt     # Python 依赖
├── README.md           # 项目说明
├── config/
│   └── config.yaml     # 配置文件
├── modules/
│   ├── __init__.py
│   ├── system_info.py  # 系统信息概览
│   ├── cpu.py          # CPU 检测
│   ├── memory.py       # 内存检测
│   ├── storage.py      # 存储检测
│   ├── sensors.py      # 传感器监控
│   ├── gpu.py          # 显卡检测
│   └── log_analyzer.py # 日志分析
└── tests/              # 测试文件

注意事项

  1. 权限要求:大多数硬件诊断功能需要 root 权限运行
  2. 压力测试:全面诊断中的压力测试会占用大量系统资源,建议在维护窗口期进行
  3. 数据安全:存储设备坏块扫描可能破坏数据,请谨慎使用

许可证

MIT License