about summary refs log tree commit diff
path: root/nixos/modules/services/monitoring
diff options
context:
space:
mode:
authorMatt Moriarity <matt@mattmoriarity.com>2024-02-18 15:47:47 -0700
committerMatt Moriarity <matt@mattmoriarity.com>2024-02-18 15:55:09 -0700
commitbbad81f93796ffaafa1f5478e8425616a2513b0f (patch)
tree2c0a457622fb94f22fa0bf627d22cb77a3caffe3 /nixos/modules/services/monitoring
parent5863c27340ba4de8f83e7e3c023b9599c3cb3c80 (diff)
downloadnixlib-bbad81f93796ffaafa1f5478e8425616a2513b0f.tar
nixlib-bbad81f93796ffaafa1f5478e8425616a2513b0f.tar.gz
nixlib-bbad81f93796ffaafa1f5478e8425616a2513b0f.tar.bz2
nixlib-bbad81f93796ffaafa1f5478e8425616a2513b0f.tar.lz
nixlib-bbad81f93796ffaafa1f5478e8425616a2513b0f.tar.xz
nixlib-bbad81f93796ffaafa1f5478e8425616a2513b0f.tar.zst
nixlib-bbad81f93796ffaafa1f5478e8425616a2513b0f.zip
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}
     '';
   };
 }