nixos/prometheus-wireguard-exporter: add support for new flags

HE7086 ab2dc5c3 3a1f517d

Changed files
+25 -3
nixos
modules
services
monitoring
prometheus
exporters
+25 -3
nixos/modules/services/monitoring/prometheus/exporters/wireguard.nix
···
mkEnableOption
optionalString
escapeShellArg
+
concatStringsSep
+
concatMapStringsSep
;
in
{
port = 9586;
imports = [
(mkRenamedOptionModule [ "addr" ] [ "listenAddress" ])
-
({
+
{
options.warnings = options.warnings;
options.assertions = options.assertions;
-
})
+
}
];
extraOpts = {
verbose = mkEnableOption "verbose logging mode for prometheus-wireguard-exporter";
···
'';
};
+
interfaces = mkOption {
+
type = types.listOf types.str;
+
default = [ ];
+
description = ''
+
Specifies the interface(s) passed to the wg show <interface> dump parameter.
+
By default all interfaces are used.
+
'';
+
};
+
singleSubnetPerField = mkOption {
type = types.bool;
default = false;
···
Adds the `wireguard_latest_handshake_delay_seconds` metric that automatically calculates the seconds passed since the last handshake.
'';
};
+
+
prependSudo = mkOption {
+
type = types.bool;
+
default = false;
+
description = ''
+
Whether or no to prepend sudo to wg commands.
+
'';
+
};
};
serviceOpts = {
path = [ pkgs.wireguard-tools ];
···
${optionalString cfg.singleSubnetPerField "-s true"} \
${optionalString cfg.withRemoteIp "-r true"} \
${optionalString cfg.latestHandshakeDelay "-d true"} \
-
${optionalString (cfg.wireguardConfig != null) "-n ${escapeShellArg cfg.wireguardConfig}"}
+
${optionalString cfg.prependSudo "-a true"} \
+
${optionalString (cfg.wireguardConfig != null) "-n ${escapeShellArg cfg.wireguardConfig}"} \
+
${concatMapStringsSep " " (i: "-i ${i}") cfg.interfaces} \
+
${concatStringsSep " " cfg.extraFlags}
'';
RestrictAddressFamilies = [
# Need AF_NETLINK to collect data