Skip to content

Laityperfect7/PCHealthAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🖥️ PCHealthAgent

全方位电脑健康筛查 / 诊断 / 修复助手 — 跨平台支持 Windows 10/11 和 Linux

Python Platform License


✨ 功能一览

功能 说明
🔍 综合诊断 OS/内存/CPU/硬盘 SMART/事件日志/蓝屏分析/网络/温度/显卡驱动/启动项/系统更新
🗑️ 垃圾扫描 临时文件 / 缓存 / 日志 / 下载目录 / 回收站 / 旧更新包 / 失效快捷方式 — 7 类全覆盖
🧹 安全清理 扫描→标记→确认→删除,默认 --dry-run 预览,支持 --auto-safe 自动清安全项
📊 实时监控 终端面板实时刷新 CPU/内存/磁盘IO/网络/温度,超阈值告警
📋 报告导出 控制台彩色报告 / HTML 深色主题报告 / JSON 结构化数据
🔧 一键修复 sfc / DISM / chkdsk / 启动项优化,自动检测管理员权限
定时任务 Windows Task Scheduler / Linux crontab,每 N 小时快检 + 每日全检

🚀 快速开始

环境要求

  • Python 3.9+
  • pip

安装

# 克隆仓库
git clone https://github.com/YOUR_USERNAME/PCHealthAgent.git
cd PCHealthAgent

# 安装依赖
pip install -r requirements.txt

# 开发模式安装(可选,使 `pchealth` 命令全局可用)
pip install -e .

基本使用

# 方式一:模块运行(推荐,无需安装)
python -m pchealth scan

# 方式二:pip install -e . 后直接使用命令
pchealth scan

📖 命令参考

scan — 综合全扫描

python -m pchealth scan              # 完整诊断 + 垃圾扫描
python -m pchealth scan --quick      # 快速扫描(跳过耗时项目)
python -m pchealth scan -o report.html  # 导出 HTML 报告
python -m pchealth scan -o data.json    # 导出 JSON 数据

junk — 垃圾文件扫描

python -m pchealth junk                    # 扫描全部 7 类
python -m pchealth junk -c temp -c cache   # 仅扫描临时文件和缓存
python -m pchealth junk --min-age 14       # 仅标记 14 天前的文件

clean — 交互式清理

python -m pchealth clean --dry-run         # 仅预览,不删除(推荐首次使用)
python -m pchealth clean --auto-safe       # 自动清理安全类别(Temp/回收站)

monitor — 实时监控面板

python -m pchealth monitor                    # 默认 10 分钟,3 秒刷新
python -m pchealth monitor -d 30 -r 1         # 30 分钟,1 秒刷新
python -m pchealth monitor -d 0               # 持续运行直到 Ctrl+C

report — 健康报告

python -m pchealth report                     # 控制台彩色报告
python -m pchealth report -f html -o health.html  # HTML 报告
python -m pchealth report -f json -o health.json  # JSON 数据

repair — 一键修复

python -m pchealth repair                     # 运行所有修复 (sfc+dism+chkdsk+startup)
python -m pchealth repair -c sfc -c dism      # 仅运行 SFC + DISM

schedule — 定时任务

python -m pchealth schedule --install         # 安装定时任务(每4h快检 + 每日全检)
python -m pchealth schedule --install --interval 2  # 每 2 小时快检
python -m pchealth schedule --uninstall       # 移除定时任务

🏗️ 项目结构

PCHealthAgent/
├── README.md
├── pyproject.toml
├── requirements.txt
├── pchealth/
│   ├── __init__.py              # 包入口、版本信息
│   ├── __main__.py              # python -m pchealth 入口
│   ├── cli.py                   # Click CLI (7 个命令)
│   ├── config.py                # 配置管理 (JSON)
│   ├── constants.py             # BugCheck 表、阈值、平台检测
│   ├── scanner/                 # 垃圾扫描器 (7 类)
│   │   ├── temp_files.py        # 临时文件
│   │   ├── cache_files.py       # 缓存文件
│   │   ├── log_files.py         # 日志文件
│   │   ├── download_junk.py     # 下载目录
│   │   ├── recycle_bin.py       # 回收站
│   │   ├── old_updates.py       # 旧更新缓存
│   │   └── broken_links.py      # 失效快捷方式
│   ├── diagnostics/             # 诊断模块 (8 项)
│   │   ├── system_info.py       # 系统信息
│   │   ├── disk_health.py       # 硬盘健康
│   │   ├── event_log.py         # 事件日志 + 蓝屏分析
│   │   ├── network.py           # 网络连通性
│   │   ├── temperature.py       # 温度检测
│   │   ├── gpu_driver.py        # 显卡驱动
│   │   ├── startup.py           # 启动项
│   │   └── updates.py           # 系统更新
│   ├── repair/                  # 修复工具
│   │   ├── system_files.py      # sfc / DISM
│   │   ├── disk_check.py        # chkdsk / fsck
│   │   └── startup_optimize.py  # 启动项优化
│   ├── monitor/
│   │   └── live.py              # 实时监控面板 (rich)
│   ├── reporter/
│   │   ├── console.py           # 控制台彩色报告
│   │   └── html_report.py       # HTML 报告
│   └── scheduler/
│       ├── windows.py           # Windows 计划任务
│       └── linux.py             # Linux crontab
└── config/
    └── default.json             # 默认配置

🔧 配置

默认配置位于 config/default.json,首次运行后自动复制到:

  • Windows: %LOCALAPPDATA%\PCHealthAgent\settings.json
  • Linux: ~/.config/PCHealthAgent/settings.json

可自定义阈值、扫描路径等:

{
    "thresholds": {
        "cpu_temp_c_warn": 75,
        "cpu_temp_c_crit": 90,
        "disk_free_gb_warn": 20,
        "driver_age_days_warn": 365
    }
}

🛡️ 安全设计

  • ✅ 所有清理操作默认 --dry-run(仅预览)
  • clean 命令需要 --auto-safe 才自动删除
  • ✅ 下载目录文件全部标记 safe_to_delete=false,需手动审核
  • repair 命令执行 sfc/dism 前检测管理员权限
  • ✅ 扫描阶段只读不改写,零风险

🌍 跨平台支持

功能 Windows Linux
系统信息
硬盘 SMART ✅ wmic ✅ smartctl
事件日志 ✅ Event Log ✅ journalctl
蓝屏分析 ✅ BugCheck 解读 N/A
温度检测 ✅ WMI/ACPI ✅ /sys/class/thermal
网络连通
启动项 ✅ 注册表 ✅ autostart
垃圾扫描
定时任务 ✅ schtasks ✅ crontab
实时监控

📝 License

MIT © PCHealth Contributors


🤝 贡献

欢迎提交 Issue 和 Pull Request!

About

Comprehensive PC Health Diagnostics, Monitoring & Repair — cross-platform for Win10/Win11/Linux.CLI + Web dashboard for system diagnostics, junk cleaning, real-time monitoring, BSOD analysis, AI-powered health insights, and one-click repair. Supports Windows & Linux.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors