enable smartd monitoring, increase upload limit, rekey
This commit is contained in:
44
modules/services/smartd.nix
Normal file
44
modules/services/smartd.nix
Normal file
@@ -0,0 +1,44 @@
|
||||
{ config, pkgs, inputs, system, lib, ... }:
|
||||
let
|
||||
notifyScript = pkgs.writeScript "smartd-notify.sh" ''
|
||||
#!${pkgs.runtimeShell}
|
||||
source ${config.age.secrets.webhook-smartd.path}
|
||||
MSG=$(
|
||||
${pkgs.coreutils}/bin/cat <<EOF
|
||||
Problem detected with disk: $SMARTD_DEVICESTRING
|
||||
Warning message from smartd is:
|
||||
|
||||
$SMARTD_FULLMESSAGE
|
||||
EOF
|
||||
)
|
||||
JSON=$(${pkgs.jq}/bin/jq -n --arg msg "$MSG" '{content: $msg}')
|
||||
${pkgs.curl}/bin/curl --request POST \
|
||||
--url "$WEBHOOK_URL" \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data "$JSON"
|
||||
'';
|
||||
cfg = config.custom.services.smartd;
|
||||
in {
|
||||
|
||||
options.custom.services.smartd = {
|
||||
enable = lib.mkEnableOption "Enables smartd monitoring";
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
age.secrets.webhook-smartd = {
|
||||
file = ../../secrets/webhook.age;
|
||||
mode = "444";
|
||||
};
|
||||
|
||||
services.smartd = {
|
||||
enable = true;
|
||||
autodetect = true;
|
||||
notifications = {
|
||||
x11.enable = false;
|
||||
wall.enable = false;
|
||||
mail.enable = false;
|
||||
};
|
||||
defaults.autodetected =
|
||||
"-a -o on -s (S/../.././02|L/../../7/04) -m <nomailer> -M exec ${notifyScript} -M test";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user