fix: add k8s and hpc modules to main repo
This commit is contained in:
58
modules/hpc/infiniband-exporter.nix
Normal file
58
modules/hpc/infiniband-exporter.nix
Normal file
@@ -0,0 +1,58 @@
|
||||
{pkgs, config, lib, ...}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.features.monitoring.infiniband-exporter;
|
||||
|
||||
python-env = pkgs.python3.withPackages (ps: with ps; [
|
||||
prometheus_client
|
||||
]
|
||||
);
|
||||
|
||||
exporter = pkgs.fetchFromGitHub {
|
||||
owner = "guilbaults";
|
||||
repo = "infiniband-exporter";
|
||||
rev = "12e7b2de049fc3c33c44e164f426dd723c8479c0";
|
||||
hash = "sha256-+n09beiJEgOgX+3po7fjiwZrziug+5N4JHi7ivTYa9U=";
|
||||
};
|
||||
|
||||
nameMap = pkgs.writeTextFile {
|
||||
name = "infiniband-node-name-map.txt";
|
||||
text = cfg.nameMap;
|
||||
};
|
||||
|
||||
infiniband-exporter-service = {
|
||||
systemd.services.infiniband-exporter = {
|
||||
enable = true;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
description = "Prometheus InfiniBand exporter";
|
||||
path = [ pkgs.rdma-core ];
|
||||
script = "${python-env}/bin/python3 ${exporter}/infiniband-exporter.py"
|
||||
+ " --port ${builtins.toString cfg.port} --can-reset-counter"
|
||||
+ (if cfg.nameMap == null then "" else " --node-name-map=${nameMap}");
|
||||
serviceConfig = {
|
||||
RestartSec = "15s";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
options.features.monitoring.infiniband-exporter = {
|
||||
enable = mkEnableOption "Enable InfiniBand prometheus exporter";
|
||||
|
||||
port = mkOption {
|
||||
type = types.ints.unsigned;
|
||||
default = 9683;
|
||||
description = "Collector http port";
|
||||
};
|
||||
|
||||
nameMap = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "Node name map";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable infiniband-exporter-service;
|
||||
}
|
||||
Reference in New Issue
Block a user