diff --git a/modules/monitoring.nix b/modules/monitoring.nix index 33d5ded..8b1225c 100644 --- a/modules/monitoring.nix +++ b/modules/monitoring.nix @@ -2,28 +2,48 @@ with pkgs; -{ +let + sender = "akasroua@disroot.org"; + recipient = "akasroua+smart@disroot.org"; + +in { # Notify when a disk starts going haywire services.smartd = { enable = true; notifications.mail = { enable = true; - sender = "akasroua+smartd@disroot.org"; - recipient = "akasroua@disroot.org"; + sender = sender; + recipient = recipient; mailer = "${msmtp}/bin/msmtp -t --read-envelope-from"; }; }; + # Notify about zpool problems + services.zfs.zed = { + enableMail = false; + settings = { + ZED_EMAIL_ADDR = [ "root" ]; + ZED_EMAIL_PROG = "${msmtp}/bin/msmtp"; + ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@"; + }; + }; + + # HACK Use an alias to use msmtp instead of the ZED mailer + environment.etc.aliases.text = '' + root: ${recipient} + ''; + # Set up msmtp as notifier programs.msmtp = { enable = true; defaults = { + auth = true; + aliases = "/etc/aliases"; port = 587; tls = true; }; accounts = { default = { - auth = true; host = "disroot.org"; user = "akasroua@disroot.org"; passwordeval = "${coreutils}/bin/cat ${config.age.secrets.msmtp.path}";