fix: add k8s and hpc modules to main repo
This commit is contained in:
67
modules/hpc/slurm-exporter.nix
Normal file
67
modules/hpc/slurm-exporter.nix
Normal file
@@ -0,0 +1,67 @@
|
||||
{pkgs, config, lib, ...}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.features.monitoring.slurm-exporter;
|
||||
|
||||
slurm-exporter-service = {
|
||||
systemd.services.slurm-exporter = {
|
||||
enable = true;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
description = "Prometheus SLURM exporter";
|
||||
script = ''
|
||||
PATH=$(${pkgs.nix}/bin/nix-store -q --referrers ${pkgs.slurm} | ${pkgs.gnugrep}/bin/grep wrappedSlurm)/bin
|
||||
${slurm-exporter}/bin/prometheus-slurm-exporter -listen-address :${builtins.toString cfg.port}
|
||||
'';
|
||||
serviceConfig = {
|
||||
RestartSec = "15s";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
slurm-exporter = pkgs.buildGoModule rec {
|
||||
pname = "prometheus-slurm-exporter";
|
||||
version = "master";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "vpenso";
|
||||
repo = "prometheus-slurm-exporter";
|
||||
rev = "master";
|
||||
sha256 = "sha256-KS9LoDuLQFq3KoKpHd8vg1jw20YCNRJNJrnBnu5vxvs=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-A1dd9T9SIEHDCiVT2UwV6T02BSLh9ej6LC/2l54hgwI=";
|
||||
|
||||
nativeBuildInputs = [ pkgs.slurm ];
|
||||
|
||||
# subPackages = [ "." ];
|
||||
|
||||
# deleteVendor = true;
|
||||
|
||||
# runVend = true;
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Simple command-line snippet manager, written in Go";
|
||||
homepage = "https://github.com/knqyf263/pet";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ kalbasit ];
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
options.features.monitoring.slurm-exporter = {
|
||||
enable = mkEnableOption "Enable SLURM prometheus exporter";
|
||||
|
||||
port = mkOption {
|
||||
type = types.ints.unsigned;
|
||||
default = 8080;
|
||||
description = "Collector http port";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable slurm-exporter-service;
|
||||
}
|
||||
Reference in New Issue
Block a user