Merge pull request #289863 from mjm/nut-exporter-variables

nixos/prometheus-nut-exporter: use extraFlags, add nutVariables option
This commit is contained in:
Jon Seager 2024-02-27 11:11:30 +00:00 committed by GitHub
commit d0b85d47c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,6 +36,17 @@ in
provisioned outside of Nix store.
'';
};
nutVariables = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
List of NUT variable names to monitor.
If no variables are set, all numeric variables will be exported automatically.
See the [upstream docs](https://github.com/DRuggeri/nut_exporter?tab=readme-ov-file#variables-and-information)
for more information.
'';
};
};
serviceOpts = {
script = ''
@ -44,7 +55,9 @@ in
${pkgs.prometheus-nut-exporter}/bin/nut_exporter \
--nut.server=${cfg.nutServer} \
--web.listen-address="${cfg.listenAddress}:${toString cfg.port}" \
${optionalString (cfg.nutUser != "") "--nut.username=${cfg.nutUser}"}
${optionalString (cfg.nutUser != "") "--nut.username=${cfg.nutUser}"} \
${optionalString (cfg.nutVariables != []) "--nut.vars_enable=${concatStringsSep "," cfg.nutVariables}"} \
${concatStringsSep " " cfg.extraFlags}
'';
};
}