Adaped status mails for lisa

This commit is contained in:
Julien Malka 2022-01-13 01:31:49 +01:00
parent 44bf16ddf0
commit fa7660ddfc
No known key found for this signature in database
GPG key ID: 3C68E13964FEA07F
3 changed files with 26 additions and 7 deletions

View file

@ -25,6 +25,11 @@
enable = true;
subdomain = "ci";
};
zfs-mails = {
enable = true;
name = "lisa";
smart.enable = false;
};
};

View file

@ -19,6 +19,8 @@ in
subdomain = "cloud";
};
zfs-mails.enable = true;
zfs-mails.name = hostName;
zfs-mails.smart.enable = true;
};
networking.hostName = hostName;

View file

@ -26,7 +26,7 @@ let
];
});
hostName = "newton";
hostName = cfg.name;
sendEmailEvent = { event }: ''
printf "Subject: ${hostName} ${event} ''$(${pkgs.coreutils}/bin/date --iso-8601=seconds)\n\nzpool status:\n\n''$(${pkgs.zfs}/bin/zpool status)" | ${pkgs.msmtp}/bin/msmtp -a default ${emailTo}
'';
@ -36,10 +36,14 @@ with lib;
{
options.luj.zfs-mails = {
enable = mkEnableOption "enable zfs status mails";
name = mkOption {
type = types.str;
};
smart.enable = mkEnableOption "enable smart deamon";
};
config = mkIf cfg.enable {
config = mkIf cfg.enable (mkMerge [{
nixpkgs.config.packageOverrides = pkgs: {
zfsStable = customizeZfs pkgs.zfsStable;
@ -63,10 +67,7 @@ with lib;
ZED_EMAIL_OPTS = "-a 'FROM:${emailFrom}' -s '@SUBJECT@' @ADDRESS@";
ZED_NOTIFY_VERBOSE = true;
};
services.smartd.enable = true;
services.smartd.notifications.mail.enable = true;
services.smartd.notifications.mail.sender = emailFrom;
services.smartd.notifications.mail.recipient = emailTo;
systemd.services."boot-mail-alert" = {
wantedBy = [ "multi-user.target" ];
@ -99,7 +100,18 @@ with lib;
};
}
(mkIf cfg.smart.enable {
services.smartd.enable = true;
services.smartd.notifications.mail.enable = true;
services.smartd.notifications.mail.sender = emailFrom;
services.smartd.notifications.mail.recipient = emailTo;
})
]);
}