Disk Health SMART Summary

Easy Shell Observability Asked at Seagate
Solve this problem

Summarise SMART attributes for every block device and flag any drive whose reallocated sector count or pending sector count is non-zero.

Constraints

  • Iterate over /dev/sd* devices.
  • Parse attributes 5 (reallocated) and 197 (pending).
  • Print device, both counts and an OK or WARN verdict.
  • Skip devices smartctl cannot read, with a note.
  • Exit 1 if any device warns.
  • Do not require root to fail gracefully.
Starter codeShell
1#!/bin/sh2# TODO: summarise SMART health