diff --git a/m/hut/monitoring.nix b/m/hut/monitoring.nix index b455c1d..e84dbe9 100644 --- a/m/hut/monitoring.nix +++ b/m/hut/monitoring.nix @@ -1,6 +1,8 @@ { config, lib, ... }: { + imports = [ ../module/slurm-exporter.nix ]; + services.grafana = { enable = true; settings = { @@ -73,6 +75,7 @@ "127.0.0.1:9323" "127.0.0.1:9252" "127.0.0.1:${toString config.services.prometheus.exporters.smartctl.port}" + "127.0.0.1:9341" # Slurm exporter ]; }]; } diff --git a/m/module/slurm-exporter.nix b/m/module/slurm-exporter.nix new file mode 100644 index 0000000..87b047d --- /dev/null +++ b/m/module/slurm-exporter.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +# See also: https://github.com/NixOS/nixpkgs/pull/112010 + +with lib; + +{ + users = { + users."slurm-exporter" = { + description = "Prometheus slurm exporter service user"; + isSystemUser = true; + group = "slurm-exporter"; + }; + groups = { + "slurm-exporter" = {}; + }; + }; + + systemd.services."prometheus-slurm-exporter" = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + Restart = mkDefault "always"; + PrivateTmp = mkDefault true; + WorkingDirectory = mkDefault "/tmp"; + DynamicUser = mkDefault true; + User = "slurm-exporter"; + Group = "slurm-exporter"; + ExecStart = '' + ${pkgs.prometheus-slurm-exporter}/bin/prometheus-slurm-exporter --listen-address "127.0.0.1:9341" + ''; + Environment = [ "PATH=${pkgs.slurm}/bin" ]; + }; + }; +}