diff --git a/modules/monitoring.nix b/modules/monitoring.nix index 06c9cbf..e7723db 100644 --- a/modules/monitoring.nix +++ b/modules/monitoring.nix @@ -1,23 +1,45 @@ { config, lib, pkgs, ... }: +with pkgs; + { # Notify when a disk starts going haywire services.smartd = { enable = true; notifications.mail = { enable = true; - recipient = "akasroua@gmail.com"; + sender = "akasroua+smartd@disroot.org"; + recipient = "akasroua@disroot.org"; + mailer = "${msmtp}/bin/msmtp -t --read-envelope-from"; }; }; - # Enable trivial MTA for smartd notifications - services.ssmtp = { - enable = true; - useTLS = true; - useSTARTTLS = true; - domain = "gmail.com"; - hostName = "smtp.gmail.com:587"; - authUser = "akasroua@gmail.com"; - authPassFile = "/var/keys/ssmtp"; + # Notify about zpool problems + services.zfs.zed = { + enableMail = false; + settings = { + ZED_EMAIL_ADDR = "akasroua+smartd@disroot.org"; + ZED_EMAIL_PROG = "mail"; + ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@"; + ZED_NOTIFY_VERBOSE = false; + }; }; + + # Set up msmtp as notifier + programs.msmtp = { + enable = true; + defaults = { + port = 587; + tls = true; + }; + accounts = { + default = { + auth = true; + host = "disroot.org"; + user = "akasroua@disroot.org"; + passwordeval = "${coreutils}/bin/cat ${config.age.secrets.msmtp.path}"; + }; + }; + }; + }