mirror of
https://github.com/Stunkymonkey/nixos.git
synced 2025-05-24 09:54:40 +02:00
45 lines
1.1 KiB
Nix
45 lines
1.1 KiB
Nix
{ config, lib, ... }:
|
|
let
|
|
cfg = config.my.hardware.drive-monitor;
|
|
in
|
|
{
|
|
options.my.hardware.drive-monitor = with lib; {
|
|
enable = mkEnableOption "drive-monitor configuration";
|
|
|
|
OnFailureMail = mkOption {
|
|
type = types.nullOr types.str;
|
|
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;
|
|
};
|
|
};
|
|
};
|
|
|
|
# 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;
|
|
};
|
|
}
|
|
];
|
|
}
|
|
];
|
|
};
|
|
}
|