diff --git a/m/hut/monitoring.nix b/m/hut/monitoring.nix index b455c1d6cb6680ac7fa56106aedad60d115c4458..6c7d09372c1b6333a780c342d9337c7e89c1aabd 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 = { @@ -12,6 +14,7 @@ http_addr = "127.0.0.1"; }; feature_toggles.publicDashboards = true; + "auth.anonymous".enabled = true; }; }; @@ -73,6 +76,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 0000000000000000000000000000000000000000..ad31f45748fe6bb94a3f785464ed626778edf165 --- /dev/null +++ b/m/module/slurm-exporter.nix @@ -0,0 +1,28 @@ +{ config, lib, pkgs, ... }: + +# See also: https://github.com/NixOS/nixpkgs/pull/112010 +# And: https://github.com/NixOS/nixpkgs/pull/115839 + +with lib; + +{ + 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; + ExecStart = '' + ${pkgs.prometheus-slurm-exporter}/bin/prometheus-slurm-exporter --listen-address "127.0.0.1:9341" + ''; + Environment = [ + "PATH=${pkgs.slurm}/bin" + # We need to specify the slurm config to be able to talk to the slurmd + # daemon. + "SLURM_CONF=${config.services.slurm.etcSlurm}/slurm.conf" + ]; + }; + }; +} diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix index 03208c5f5cc8bb74c60b9f30c5e743264ce4e69b..47a4f3a637c433101681dcd0e7845ec8e92f9a1d 100644 --- a/pkgs/overlay.nix +++ b/pkgs/overlay.nix @@ -32,4 +32,6 @@ final: prev: lua = prev.lua5_4; fmt = prev.fmt_8; }) ceph ceph-client; + + prometheus-slurm-exporter = prev.callPackage ./slurm-exporter.nix { }; } diff --git a/pkgs/slurm-exporter.nix b/pkgs/slurm-exporter.nix new file mode 100644 index 0000000000000000000000000000000000000000..49070cd74fa76cc458af5012dcd1b30329a95e9f --- /dev/null +++ b/pkgs/slurm-exporter.nix @@ -0,0 +1,22 @@ +{ buildGoModule, fetchFromGitHub, lib }: + +buildGoModule rec { + pname = "prometheus-slurm-exporter"; + version = "0.20"; + + src = fetchFromGitHub { + rev = version; + owner = "vpenso"; + repo = pname; + sha256 = "sha256-KS9LoDuLQFq3KoKpHd8vg1jw20YCNRJNJrnBnu5vxvs="; + }; + + vendorSha256 = "sha256-A1dd9T9SIEHDCiVT2UwV6T02BSLh9ej6LC/2l54hgwI="; + doCheck = false; + + meta = with lib; { + description = "Prometheus SLURM Exporter"; + homepage = "https://github.com/vpenso/prometheus-slurm-exporter"; + platforms = platforms.linux; + }; +}