mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-20 22:41:28 +01:00
* fix(ai): relax NVMe power-management workarounds and enable smartd Logs show no NVMe errors, so allow APST again (capped at 100 ms), restore the default io_timeout, and drop pcie_aspm=off. Add smartd for drive health visibility. * feat(storage): add drive/SSD SMART monitoring on physical hosts node_exporter's nvme collector only exposes node_nvme_info and namespace capacity, not SMART health, so SSD wear/lifespan and drive temperature were not observable anywhere. - enable services.prometheus.exporters.smartctl on physical hosts, gated on modules.hardwareTools (off on QEMU/MicroVM guests), bound to the host's LAN address on port 9633 - firewall: drop 9633 from anything but the monitoring host - youko: scrape smartctl-<host> for the physical hosts - alert rules (storage.yml): SMART health, NVMe wear, available spare, media errors, critical warning, and drive temperature (warn 70 / crit 80 C) - Grafana dashboard "Drive SMART (smartctl)"
49 lines
1.7 KiB
Nix
49 lines
1.7 KiB
Nix
{ lib, myvars, ... }:
|
|
let
|
|
inherit (myvars.networking) lanCidr;
|
|
# The host that scrapes the exporters (VictoriaMetrics runs on youko).
|
|
monitoringHost = myvars.networking.hostsAddr.youko.ipv4;
|
|
in
|
|
{
|
|
# Hosts bring their own firewall as defence in depth behind the router's
|
|
# (which stays on, with port mappings for the few ports we need): the home
|
|
# LAN and the tailnet are trusted equally (tighten the tailnet with Tailscale
|
|
# ACLs), and everything else is denied on both address families.
|
|
networking.nftables.enable = true;
|
|
|
|
networking.firewall = {
|
|
enable = true;
|
|
|
|
# Nothing is opened to the Internet. LAN/tailnet/local-container access
|
|
# comes from the rules below; per-service `openFirewall` ports are
|
|
# suppressed.
|
|
allowedTCPPorts = lib.mkForce [ ];
|
|
allowedUDPPorts = lib.mkForce [ ];
|
|
|
|
extraInputRules = ''
|
|
# node_exporter is scraped only by the monitoring host, not the whole
|
|
# LAN/tailnet/local containers.
|
|
ip saddr != ${monitoringHost} tcp dport 9100 drop
|
|
|
|
# The NVIDIA GPU exporter (desktop only) is likewise scraped only by the
|
|
# monitoring host.
|
|
ip saddr != ${monitoringHost} tcp dport 9835 drop
|
|
|
|
# smartctl_exporter (drive/SSD SMART health) is scraped only by the
|
|
# monitoring host.
|
|
ip saddr != ${monitoringHost} tcp dport 9633 drop
|
|
|
|
# The local container bridge and the tailnet have the same access as the
|
|
# LAN. Kept after the drop above so neither can reach node_exporter.
|
|
iifname "podman0" accept
|
|
iifname "tailscale0" accept
|
|
|
|
# The home LAN is the trusted core.
|
|
ip saddr ${lanCidr} accept
|
|
ip6 saddr fe80::/10 accept
|
|
# Tailscale's WireGuard port, for direct (non-DERP) connections.
|
|
udp dport 41641 accept
|
|
'';
|
|
};
|
|
}
|