ZFS: Difference between revisions
imported>Bryanasdev000 m Add comment per https://github.com/NixOS/nixpkgs/issues/106093 |
imported>2r Mail notification for ZFS Event Daemon |
||
Line 509: | Line 509: | ||
* https://discourse.nixos.org/t/zfs-dedup-on-nix-store-is-it-worth-it/4959 | * https://discourse.nixos.org/t/zfs-dedup-on-nix-store-is-it-worth-it/4959 | ||
* https://discourse.nixos.org/t/how-to-add-extra-build-input-to-linux-kernel/8208/3 | * https://discourse.nixos.org/t/how-to-add-extra-build-input-to-linux-kernel/8208/3 | ||
==Mail notification for ZFS Event Daemon== | |||
ZFS Event Daemon (zed) monitors events generated by the ZFS kernel module and runs configured tasks. It can be configured to send an email when a pool scrub is finished or a disk has failed. | |||
First, we need to configure a mail transfer agent, the program that sends email: | |||
<pre> | |||
{ | |||
programs.msmtp = { | |||
enable = true; | |||
setSendmail = true; | |||
defaults = { | |||
aliases = "/etc/aliases"; | |||
port = 465; | |||
tls_trust_file = "/etc/ssl/certs/ca-certificates.crt"; | |||
tls = "on"; | |||
auth = "login"; | |||
tls_starttls = "off"; | |||
}; | |||
accounts = { | |||
default = { | |||
host = "mail.example.com"; | |||
passwordeval = "cat /etc/emailpass.txt"; | |||
user = "user@example.com"; | |||
from = "user@example.com"; | |||
}; | |||
}; | |||
}; | |||
} | |||
</pre> | |||
Then, configure an alias for root account. With this alias configured, all mails sent to root, such as cron job results and failed sudo login events, will be redirected to the configured email account. | |||
<pre> | |||
tee -a /etc/aliases <<EOF | |||
root: user@example.com | |||
EOF | |||
</pre> | |||
Finally, override default zed settings with a custom one: | |||
<pre> | |||
{ | |||
services.zfs.zed.settings = | |||
{ | |||
ZED_DEBUG_LOG = "/tmp/zed.debug.log"; | |||
ZED_EMAIL_ADDR = [ "root" ]; | |||
ZED_EMAIL_PROG = "${ pkgs.msmtp }/bin/msmtp"; | |||
ZED_EMAIL_OPTS = "@ADDRESS@"; | |||
ZED_NOTIFY_INTERVAL_SECS = 3600; | |||
ZED_NOTIFY_VERBOSE = true; | |||
ZED_USE_ENCLOSURE_LEDS = true; | |||
ZED_SCRUB_AFTER_RESILVER = true; | |||
}; | |||
# this option does not work; will return error | |||
services.zfs.zed.enableMail = false; | |||
} | |||
</pre> | |||
You can now test this by performing a scrub | |||
<pre> | |||
zpool scrub $pool | |||
</pre> |