返回顶部
d

disk-guardian磁盘卫士

Run S.M.A.R.T. diagnostics on all drives, parse health indicators, maintain a history log, and flag drives showing early failure patterns. Generates health summaries and "drives ranked by risk" reports. Works on macOS and Linux. Use when the user asks about disk health, drive health, SMART diagnostics, hard drive status, SSD health, disk status, whether their drives are ok, or wants to check for failing drives.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
107
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

disk-guardian

disk-guardian

适用于macOS和Linux的S.M.A.R.T.硬盘健康扫描工具。

脚本

所有脚本位于scripts/目录下。按顺序运行或通过管道串联:

bash
cd ~/.openclaw/workspace/skills/disk-guardian/scripts

完整流程(Linux上可能需要sudo权限):

python3 scandrives.py | python3 parsesmart.py | python3 report.py

使用sudo(许多Linux系统需要):

python3 scandrives.py --sudo | python3 parsesmart.py | python3 report.py

保存报告到文件:

python3 scandrives.py | python3 parsesmart.py | python3 report.py --output ~/disk-report.md

记录扫描历史并获取趋势分析:

python3 scandrives.py | python3 parsesmart.py | python3 history.py --record

数据默认存储在~/.openclaw/workspace/disk-guardian/目录下。可在任意脚本中使用--data-dir参数覆盖默认路径。

工作流程

  1. 1. 运行scandrives.py — 检测硬盘并对每个硬盘执行smartctl -a命令,输出JSON格式数据。
  2. 通过管道传递给parsesmart.py — 提取健康属性,评估状态(良好/警告/严重)。
  3. 通过管道传递给report.py — 生成包含风险评级和建议的Markdown报告。
  4. 可选:通过管道传递给history.py --record记录扫描结果并获取趋势告警。

前置条件

必须安装smartctl:

  • - macOS:brew install smartmontools
  • Linux:sudo apt install smartmontools 或 sudo dnf install smartmontools

如果缺少smartctl,scan_drives.py会输出安装命令并优雅退出。

脚本详情

scan_drives.py

  • - macOS:使用diskutil list查找完整磁盘,然后执行smartctl -a /dev/diskN
  • Linux:使用lsblk查找块设备,然后执行smartctl -a /dev/sdX
  • --sudo:在smartctl命令前添加sudo(Linux上无udev规则时需要)
  • 输出JSON:{os, smartctlpath, drivesfound, scanresults: [{device, smartctloutput|error}]}

parse_smart.py

  • - 检测硬盘类型:NVMe、SSD或HDD
  • SATA/SSD:解析属性表,提取重映射扇区计数、当前待处理扇区、不可纠正错误、温度、通电时间、读取错误率、寻道错误率等
  • NVMe:解析健康日志,获取可用备用空间、使用百分比、介质错误、不安全关机次数、严重警告
  • 分配健康状态:良好/警告/严重
  • --input FILE:从文件读取而非标准输入
  • --raw FILE --device NAME:解析单个原始smartctl文本转储

history.py

  • - --record:将当前扫描结果追加到~/.openclaw/workspace/disk-guardian/history.json
  • --trends:分析存储的历史数据,发现异常模式(重映射扇区增加、温度升高、NVMe备用空间减少)
  • --list [--limit N]:显示每个设备最近N条记录
  • --data-dir PATH:使用替代存储位置
  • --device /dev/diskN:过滤输出到指定设备

report.py

  • - 生成包含硬盘清单表、各硬盘状态、带评分的风险排名、可读标志说明、趋势告警和建议的Markdown报告
  • 风险排名考虑健康状态、标志严重性、趋势告警和硬盘年龄(通电时间)
  • --output FILE:将报告保存到文件而非打印
  • --trends FILE:加载预计算的趋势JSON数据

SMART属性参考

参见references/smart-attributes.md,了解10个最关键SMART属性和NVMe健康指标的通俗解释。在向用户解释特定属性或排查标记硬盘时阅读此文档。

边界情况

  • - 未安装smartctl:scan_drives.py打印安装说明并以代码2退出
  • 权限被拒绝:输出包含使用--sudo的提示;在Linux上,将用户添加到disk组作为永久解决方案
  • 虚拟硬盘(VMware、loop设备):smartctl将返回错误;这些错误会被捕获并包含在错误条目中
  • NVMe vs SATA:自动检测硬盘类型;NVMe使用健康日志字段而非属性表
  • 历史数据损坏:history.py自动备份文件并重新开始

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 disk-guardian-1775932743 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 disk-guardian-1775932743 技能

通过命令行安装

skillhub install disk-guardian-1775932743

下载

⬇ 下载 disk-guardian v1.0.0(免费)

文件大小: 20.04 KB | 发布时间: 2026-4-12 09:45

v1.0.0 最新 2026-4-12 09:45
Initial release: S.M.A.R.T. drive health scanner for macOS and Linux. Scans drives, parses health indicators, maintains history, flags early failure patterns.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部