nixos/modules/hardware/drive-monitor/default.nix

46 lines
1.1 KiB
Nix
Raw Normal View History

2023-11-07 22:00:00 +01:00
{ config, lib, ... }:
let
cfg = config.my.hardware.drive-monitor;
in
{
options.my.hardware.drive-monitor = with lib; {
enable = mkEnableOption "drive-monitor configuration";
OnFailureMail = mkOption {
2023-11-07 23:13:51 +01:00
type = types.nullOr types.str;
2023-06-22 20:54:16 +02:00
description = lib.mdDoc "Mail address where to send the error report";
default = null;
example = "alarm@mail.com";
};
};
config = lib.mkIf cfg.enable {
services = {
postfix.enable = cfg.OnFailureMail != null;
smartd = {
enable = true;
notifications.mail = lib.mkIf (cfg.OnFailureMail != null) {
enable = true;
recipient = cfg.OnFailureMail;
};
};
};
2023-04-28 22:28:57 +02:00
# monitoring
services.prometheus.exporters.smartctl.enable = config.services.prometheus.enable;
services.prometheus.scrapeConfigs = [
{
job_name = "smartctl";
static_configs = [
{
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.smartctl.port}" ];
labels = {
instance = config.networking.hostName;
};
}
];
}
];
};
}