Skip to content

Add a disk-health example task, written in Python - #16

Merged
thecode merged 1 commit into
mainfrom
disk-health-example
Nov 25, 2026
Merged

thecode merged 1 commit into
mainfrom
disk-health-example

Conversation

@thecode

@thecode thecode commented Nov 25, 2026

Copy link
Copy Markdown
Owner

What

A third example task, disk-health, next to pool-health and daily-digest. Once an hour it reads the SMART data of every disk and stays quiet when all is well. It alerts on:

  • a failed SMART health check, or an attribute below its threshold;
  • reallocated sectors, sectors waiting to be reallocated, uncorrectable sectors or errors;
  • a SATA SSD with 10% of its life left or less;
  • NVMe: a critical warning, media errors, spare capacity below its threshold, or 90% of the rated life used;
  • temperature at or above 55 °C for a hard disk, 70 °C for an SSD.

How it behaves

  • Sleeping disks stay asleep. It uses smartctl -n standby, so a spun-down disk is skipped and only looked at when a check finds it awake.
  • One host call for all disks, plus one for Unraid's disk list.
  • Unraid's names. A line reads parity (model, serial): 8 reallocated sectors; a disk without a slot is named by its device.
  • Stable wording. Temperature and wear are reported as "at or above 55 °C" and "10% of its life left or less", so the same alert is not posted again each hour as the number moves. Counts are printed, so a growing count is a new alert.
  • Cable errors are left out. The CRC error count never resets and would alert for ever.
  • Limits at the top of the script. A known, stable value can be accepted by raising its limit; the changed script asks for approval again.
  • USB sticks have no SMART data and are not looked at. A server without smartctl is quiet; a failed host call is reported.

It is written in Python inside check.sh (exec python3 - <<'PY'), so the examples now also show that pattern, which the base instructions point to.

Existing installs

Examples are copied only on a first start, so an existing install does not get this one by itself. docs/tasks.md says to ask Claude to copy it from /usr/local/share/berthward/task-examples/disk-health.

Testing

  • tests/run.sh: seven new checks with made-up SMART data (healthy disks and a sleeping disk are quiet; failing SATA, SSD and NVMe disks are reported one line each under Unraid's name; no disks, no smartctl, a failed host call, a disk that does not answer). All 496 pass.
  • Run on three servers with SATA SSDs, NVMe disks and hard disks: quiet with the real limits; with the temperature limit lowered it listed every awake disk under its Unraid name, a spinning hard disk among them. The spun-down hard disks were still asleep afterwards.
  • Installed as a task on the dev server, approved on Discord and run with /run disk-health.
  • Not seen on real hardware: an actually failing disk.

A third example task that reads every disk's SMART data once an hour and alerts on a failed health check, reallocated or unreadable sectors, an SSD near the end of its rated life, NVMe warnings and overheating. A disk that is spun down is left asleep and skipped, and problems are reported under Unraid's name for the disk. It is written in Python inside check.sh, so the examples also show that pattern.
@thecode thecode added new-feature Adds a feature enhancement New feature or request and removed new-feature Adds a feature labels Nov 25, 2026
@thecode
thecode merged commit 9f0e8dc into main Nov 25, 2026
7 checks passed
@thecode
thecode deleted the disk-health-example branch November 25, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant