From 7095bdf9889cc0e412ab6d2270d3c671c39fe70a Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 21 Jul 2019 15:41:51 +0200 Subject: [PATCH] nixos/prometheus-exporters/wireguard: add support for `-s` switch Since version 3.0 all allowed IPs and subnets are exposed by the exporter. With `-s` set on the CLI, instead of a comma-separated list, each allowed IP and subnet will be in a single field with the schema `allowed_ip_`. --- .../monitoring/prometheus/exporters/wireguard.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/services/monitoring/prometheus/exporters/wireguard.nix b/nixos/modules/services/monitoring/prometheus/exporters/wireguard.nix index c5b84e574b8..eae7a61297d 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/wireguard.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/wireguard.nix @@ -23,12 +23,24 @@ in { to set the peers up. ''; }; + + singleSubnetPerField = mkOption { + type = types.bool; + default = false; + description = '' + By default, all allowed IPs and subnets are comma-separated in the + allowed_ips field. With this option enabled, + a single IP and subnet will be listed in fields like allowed_ip_0, + allowed_ip_1 and so on. + ''; + }; }; serviceOpts = { script = '' ${pkgs.prometheus-wireguard-exporter}/bin/prometheus_wireguard_exporter \ -p ${toString cfg.port} \ ${optionalString cfg.verbose "-v"} \ + ${optionalString cfg.singleSubnetPerField "-s"} \ ${optionalString (cfg.wireguardConfig != null) "-n ${cfg.wireguardConfig}"} '';