#!/bin/bash # disk-health-check.sh — argento health monitoring # Checks SMART health (SATA and NVMe), ZFS pool state and error counters, # ZFS dataset quotas, and non-ZFS disk space. # # Output is plain text to stdout (ANSI-colored when stdout is a TTY), # or an HTML email to $MAILTO with --email. # # Usage: # disk-health-check.sh # full report to stdout # disk-health-check.sh --error-only # problems only; silent if healthy # disk-health-check.sh --email # full report by email # disk-health-check.sh --error-only --email # email only if problems found # # Cron on the server runs --error-only --email daily and --email weekly. # # Dependencies: smartmontools, zfs, msmtp (as sendmail) set -uo pipefail MAILTO="timothykim@fastmail.fm" HOSTNAME=$(hostname) SPACE_THRESHOLD=85 # percent used — alert above this ZFS_CAP_THRESHOLD=80 # ZFS write performance degrades on nearly-full pools QUOTA_THRESHOLD=85 # percent of dataset quota — alert above this ERROR_ONLY=false USE_EMAIL=false for arg in "$@"; do case "$arg" in --error-only) ERROR_ONLY=true ;; --email) USE_EMAIL=true ;; *) echo "Unknown option: $arg" >&2; exit 1 ;; esac done PROBLEMS="" STATUS="" # HTML table rows for the email body, built alongside the plain-text STATUS. # Styles are inlined on every element because most mail clients strip #