diff --git a/hosts/12kingdoms-youko/homelab-services/monitoring/victoriametrics.nix b/hosts/12kingdoms-youko/homelab-services/monitoring/victoriametrics.nix index 72d41826..61452f30 100644 --- a/hosts/12kingdoms-youko/homelab-services/monitoring/victoriametrics.nix +++ b/hosts/12kingdoms-youko/homelab-services/monitoring/victoriametrics.nix @@ -100,10 +100,12 @@ in params.ups = [ "homelab" ]; static_configs = [ { - targets = [ "${myvars.networking.hostsAddr.shushou.ipv4}:9199" ]; + # same-host nut exporter bound to loopback (127.0.0.1:9199); the + # UPS moved to this host with the SSD swap + targets = [ "127.0.0.1:9199" ]; labels.type = "app"; labels.app = "nut"; - labels.host = "shushou"; + labels.host = "youko"; labels.env = "homelab"; labels.cluster = "homelab"; } diff --git a/hosts/12kingdoms-shushou/ups.nix b/hosts/12kingdoms-youko/ups.nix similarity index 78% rename from hosts/12kingdoms-shushou/ups.nix rename to hosts/12kingdoms-youko/ups.nix index ba538632..bc40f1f7 100644 --- a/hosts/12kingdoms-shushou/ups.nix +++ b/hosts/12kingdoms-youko/ups.nix @@ -1,13 +1,12 @@ -{ myvars, ... }: -let - hostAddress = myvars.networking.hostsAddr.shushou.ipv4; -in +{ ... }: { + # The UPS (Cypress USB-to-serial, 0665:5161) is attached to this host, which is + # now the homelab core. Metrics only for now; coordinated shutdown of all + # homelab hosts is a separate feature. power.ups = { enable = true; mode = "standalone"; - # Metrics only. Coordinated shutdown of all homelab hosts is a separate feature. upsmon = { enable = false; settings.POWERDOWNFLAG = null; @@ -33,7 +32,7 @@ in services.prometheus.exporters.nut = { enable = true; - listenAddress = hostAddress; + listenAddress = "127.0.0.1"; port = 9199; nutServer = "127.0.0.1"; diff --git a/outputs/x86_64-linux/tests/ups-metrics/expected.nix b/outputs/x86_64-linux/tests/ups-metrics/expected.nix index dc98ffe4..9fde7995 100644 --- a/outputs/x86_64-linux/tests/ups-metrics/expected.nix +++ b/outputs/x86_64-linux/tests/ups-metrics/expected.nix @@ -18,7 +18,7 @@ exporter = { enable = true; - listenAddress = "192.168.5.182"; + listenAddress = "127.0.0.1"; port = 9199; nutServer = "127.0.0.1"; exportsAllNumericVariables = true; @@ -32,11 +32,11 @@ scrape_interval = "30s"; metrics_path = "/ups_metrics"; params.ups = [ "homelab" ]; - target = "192.168.5.182:9199"; + target = "127.0.0.1:9199"; labels = { type = "app"; app = "nut"; - host = "shushou"; + host = "youko"; env = "homelab"; cluster = "homelab"; }; diff --git a/outputs/x86_64-linux/tests/ups-metrics/expr.nix b/outputs/x86_64-linux/tests/ups-metrics/expr.nix index 125a5207..0f63e472 100644 --- a/outputs/x86_64-linux/tests/ups-metrics/expr.nix +++ b/outputs/x86_64-linux/tests/ups-metrics/expr.nix @@ -4,27 +4,28 @@ ... }: let - shushou = outputs.nixosConfigurations.shushou.config; - aquamarine = outputs.nixosConfigurations.youko.config; - ups = shushou.power.ups.ups.homelab or { }; - exporter = shushou.services.prometheus.exporters.nut; + # The UPS moved to youko with the SSD swap; the NUT daemons, the exporter, and + # the victoriametrics scrape job now all live on the same host. + youko = outputs.nixosConfigurations.youko.config; + ups = youko.power.ups.ups.homelab or { }; + exporter = youko.services.prometheus.exporters.nut; exporterService = - shushou.systemd.services.prometheus-nut-exporter or { + youko.systemd.services.prometheus-nut-exporter or { after = [ ]; requires = [ ]; }; scrapeJobs = builtins.filter ( job: (job.job_name or "") == "nut-exporter-homelab-ups" - ) aquamarine.services.victoriametrics.prometheusConfig.scrape_configs; + ) youko.services.victoriametrics.prometheusConfig.scrape_configs; scrapeJob = if builtins.length scrapeJobs == 1 then builtins.head scrapeJobs else null; in { nut = { - enable = shushou.power.ups.enable; - mode = shushou.power.ups.mode; - upsmonEnable = shushou.power.ups.upsmon.enable; - killPowerEnable = shushou.systemd.services.ups-killpower.enable or false; - upsdListen = shushou.power.ups.upsd.listen; + enable = youko.power.ups.enable; + mode = youko.power.ups.mode; + upsmonEnable = youko.power.ups.upsmon.enable; + killPowerEnable = youko.systemd.services.ups-killpower.enable or false; + upsdListen = youko.power.ups.upsd.listen; driver = ups.driver or null; port = ups.port or null; vendorId = builtins.elem "vendorid = 0665" (ups.directives or [ ]);