ZFS: Difference between revisions
m fix error |
update mail notification |
||
Line 450: | Line 450: | ||
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. [https://search.nixos.org/options?query=services.zfs.zed zed options] | 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. [https://search.nixos.org/options?query=services.zfs.zed zed options] | ||
First, we need to configure a mail transfer agent, the program that sends email: | First, we need to configure a mail transfer agent, the program that sends email: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
{ | { | ||
age.secrets.msmtp = { | |||
file = "${inputs.self.outPath}/secrets/msmtp.age"; | |||
}; | |||
# for zed enableMail, enable sendmailSetuidWrapper | |||
services.mail.sendmailSetuidWrapper.enable = true; | |||
programs.msmtp = { | programs.msmtp = { | ||
enable = true; | enable = true; | ||
Line 461: | Line 466: | ||
defaults = { | defaults = { | ||
aliases = "/etc/aliases"; | aliases = "/etc/aliases"; | ||
port = | port = 587; | ||
auth = "plain"; | |||
tls = "on"; | tls = "on"; | ||
tls_starttls = "on"; | |||
tls_starttls = " | |||
}; | }; | ||
accounts = { | accounts = { | ||
default = { | default = { | ||
host = "mail.example.com"; | host = "smtp.mail.example.com"; | ||
passwordeval = "cat | passwordeval = "cat ${config.age.secrets.msmtp.path}"; | ||
user = " | user = "myname@example.com"; | ||
from = " | from = "myname@example.com"; | ||
}; | }; | ||
}; | }; | ||
Line 484: | Line 488: | ||
{ | { | ||
environment.etc.aliases.text = '' | environment.etc.aliases.text = '' | ||
root: | root: admin@example.com | ||
''; | ''; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Finally, | Finally, enable zed mail notification: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
{ | { | ||
services.zfs.zed. | services.zfs.zed. = { | ||
enableMail = true; | |||
ZED_EMAIL_ADDR = [ "root" ]; | settings = { | ||
ZED_EMAIL_ADDR = [ "root" ]; | |||
# send notification if scrub succeeds | |||
ZED_NOTIFY_VERBOSE = true; | |||
}; | |||
}; | }; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 514: | Line 512: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Guide]] | [[Category:Guide]] |