January 15, 2025 · backup selfhost linux software

ZFS Health Notifications by Email

Screen-Shot-2025-08-14-at-10.43.23-AM

ZFS has been working reliably on my home server for the past 6+ years, with no failures identified during the monthly scrubs. However, I really wanted to get a push notification if any problems were identified the scrub (or similarly if no problems were found). A daemon already exists called the ZFS Event Daemon, or ZED, which monitors the health of the zpools. Since I wasn't routinely checking the ZED logs, I configured ZED in a way to be informed of a degraded pool or impending failure through email notifications.

ZED fortunately has the ability to send notifications via a SMTP server. Here are the requirements:

  • ZFS pool with ZED service
  • SMTP server (WAN access or port 25 traffic NOT required).
  • ability to redirect mail / make aliases (optional)

Step 1: Create Mail Account on SMTP Server

User accounts for simple notifications or alerts should have the least amount of system privileges. To create a user without a home folder and no login access, add the --no-create-home and --system flags respectively.

For example, to make a user called alerts, for alerts@naut.ca

sudo adduser --no-create-home --system  alerts

# to set the password
sudo passwd alerts

Step 2: Setup Mail Redirect (optional)

I set up a mail alias in order to redirect all notifications sent to the alerts account to my personal account:

# cat /etc/aliases
postmaster:yoon
alerts:yoon

# update aliases
sudo newaliases

Step 3: Setup Mailer Utilities on ZFS Host

sSMTP was chosen as the system mailer due to its ease of use. Install with:

# debian
sudo apt install mailutils ssmtp

# alpine
sudo apk add ssmtp mailx

Then update the configuration file at /etc/ssmtp/ssmtp.conf. The configuration update may require a restart to fully take effect.

root=
# SMTP server is located at cloud.naut.ca on port 465
mailhub=cloud.naut.ca:465

AuthUser=alerts
AuthPass=PASS_HERE

# Force TLS
UseTLS=YES

# Where will the mail seem to come from?
rewriteDomain=foobar.naut.ca

# The full hostname
hostname=foobar

Step 4: Setup ZED for Email Notifications

Lastly, update the ZED configuration file at /etc/zfs/zed.d/zed.rc. Make sure that ZED_EMAIL_ADDR is your destination email address. To be notified of successful ZFS scrubs, set ZED_NOTIFY_VERBOSE=1. Here are the changed lines from my configuration:

# zed.rc – ZEDLET configuration.

# multiple addresses can be specified if they are delimited by whitespace.
ZED_EMAIL_ADDR="alerts@naut.ca"

# Minimum number of seconds between notifications for a similar event.
ZED_NOTIFY_INTERVAL_SECS=3600

ZED_NOTIFY_VERBOSE=1

Finally make sure the daemon is enabled: sudo systemctl enable zfs-zed (for systemd) or sudo rc-update add zfs-zed (for OpenRC), then reboot.

Step 5: Testing

Lastly, trigger a scrub with zpool scrub POOL and wait for the success (or failure) notification!