mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-21 23:54:22 +01:00
Add disk monitoring to blowhole
Signed-off-by: magic_rb <magic_rb@redalder.org>
This commit is contained in:
parent
e8100d690e
commit
ad6a5f6784
|
@ -44,6 +44,7 @@ in
|
|||
./watchdog.nix
|
||||
./nixpkgs.nix
|
||||
./users.nix
|
||||
./disk_monitoring.nix
|
||||
./sol.nix
|
||||
../../common/remote_access.nix
|
||||
./microvms.nix
|
||||
|
|
76
nixos/systems/blowhole/disk_monitoring.nix
Normal file
76
nixos/systems/blowhole/disk_monitoring.nix
Normal file
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) concatMapStringsSep;
|
||||
|
||||
cfg = config.services.smartd;
|
||||
|
||||
smartdNotify = pkgs.writeShellScript "smartd-notify-matrix" ''
|
||||
while [[ $# > 0 ]] ; do
|
||||
case "$1" in
|
||||
-i)
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
{
|
||||
${pkgs.coreutils}/bin/cat <<EOF
|
||||
smartd on \`<blowhole>\`
|
||||
|
||||
$SMARTD_SUBJECT
|
||||
|
||||
\`\`\`
|
||||
|
||||
$SMARTD_FULLMESSAGE
|
||||
\`\`\`
|
||||
|
||||
\`\`\`
|
||||
|
||||
$(${pkgs.smartmontools}/sbin/smartctl -a -d "$SMARTD_DEVICETYPE" "$SMARTD_DEVICE")
|
||||
\`\`\`
|
||||
EOF
|
||||
} | ${pkgs.matrix-commander-rs}/bin/matrix-commander-rs -c /var/secrets/matrix-smartd.json -s /var/lib/matrix-commander --markdown -m -
|
||||
'';
|
||||
|
||||
smartdConfig = pkgs.writeText "smartd.conf" ''
|
||||
DEFAULT -m <nomailer> -M exec ${smartdNotify} -M test -a
|
||||
|
||||
${concatMapStringsSep "\n" (d: "${d.device} ${d.options}") cfg.devices}
|
||||
'';
|
||||
in {
|
||||
services.smartd = {
|
||||
# The module needs fixing
|
||||
enable = false;
|
||||
|
||||
devices = map (x: {device = "/dev/disk/by-id/" + x;}) [
|
||||
# Old Skyhawks
|
||||
"ata-ST1000VX005-2EZ102_Z9CBQKCQ"
|
||||
"ata-ST1000VX005-2EZ102_Z9CBQLDS"
|
||||
|
||||
# NAS WD Reds
|
||||
"ata-WDC_WD40EFZX-68AWUN0_WD-WX82DA1C79SK"
|
||||
"ata-WDC_WD40EFZX-68AWUN0_WD-WXA2DA1C9JKA"
|
||||
|
||||
# Boot SSD
|
||||
"ata-Apacer_AS350_128GB_2021020103001990"
|
||||
|
||||
# Database SSDs
|
||||
"nvme-KINGSTON_SA2000M8250G_50026B76844F4629"
|
||||
"nvme-KINGSTON_SA2000M8250G_50026B76851B664C"
|
||||
];
|
||||
|
||||
extraOptions = ["-M" "exec ${smartdNotify}" "-M" "test"];
|
||||
};
|
||||
|
||||
systemd.services.smartd = {
|
||||
description = "S.M.A.R.T. Daemon";
|
||||
wantedBy = ["multi-user.target"];
|
||||
serviceConfig.ExecStart = "${pkgs.smartmontools}/sbin/smartd --no-fork --configfile=${smartdConfig} -s /var/lib/smartd/";
|
||||
};
|
||||
}
|
|
@ -82,6 +82,14 @@ in
|
|||
device = "blowhole-zpool/persist/vault";
|
||||
fsType = "zfs";
|
||||
};
|
||||
"/var/lib/matrix-commander" = {
|
||||
device = "blowhole-zpool/persist/matrix-commander";
|
||||
fsType = "zfs";
|
||||
};
|
||||
"/var/lib/smartd" = {
|
||||
device = "blowhole-zpool/persist/smartd";
|
||||
fsType = "zfs";
|
||||
};
|
||||
}
|
||||
// secret.mounts.blowhole or {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue