about summary refs log tree commit diff
path: root/nixos/modules/services/monitoring
diff options
context:
space:
mode:
authorJon Seager <jon@sgrs.uk>2024-02-27 11:11:30 +0000
committerGitHub <noreply@github.com>2024-02-27 11:11:30 +0000
commitd0b85d47c63eafa5e27cff8524254ccdd0dc66c2 (patch)
tree31a91a6933acdaa42ddfc8b158f8b7624d7338da /nixos/modules/services/monitoring
parent9d422aeafc8780e1efe49f5891b70685d9c05c40 (diff)
parentbbad81f93796ffaafa1f5478e8425616a2513b0f (diff)
downloadnixlib-d0b85d47c63eafa5e27cff8524254ccdd0dc66c2.tar
nixlib-d0b85d47c63eafa5e27cff8524254ccdd0dc66c2.tar.gz
nixlib-d0b85d47c63eafa5e27cff8524254ccdd0dc66c2.tar.bz2
nixlib-d0b85d47c63eafa5e27cff8524254ccdd0dc66c2.tar.lz
nixlib-d0b85d47c63eafa5e27cff8524254ccdd0dc66c2.tar.xz
nixlib-d0b85d47c63eafa5e27cff8524254ccdd0dc66c2.tar.zst
nixlib-d0b85d47c63eafa5e27cff8524254ccdd0dc66c2.zip
Merge pull request #289863 from mjm/nut-exporter-variables
nixos/prometheus-nut-exporter: use extraFlags, add nutVariables option
Diffstat (limited to 'nixos/modules/services/monitoring')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/nut.nix15
1 files changed, 14 insertions, 1 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/nut.nix b/nixos/modules/services/monitoring/prometheus/exporters/nut.nix
index 1c86b48b4509..e58a394456a3 100644
--- a/nixos/modules/services/monitoring/prometheus/exporters/nut.nix
+++ b/nixos/modules/services/monitoring/prometheus/exporters/nut.nix
@@ -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}
     '';
   };
 }