nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/dnsmasq.nix
Martin Weinelt d702c91302
nixos/prometheus/exporters: pass utils into exporter modules
This is useful, because it provides escapeSystemdShellArgs.
2024-03-21 05:27:21 +01:00

39 lines
958 B
Nix

{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.dnsmasq;
in
{
port = 9153;
extraOpts = {
dnsmasqListenAddress = mkOption {
type = types.str;
default = "localhost:53";
description = lib.mdDoc ''
Address on which dnsmasq listens.
'';
};
leasesPath = mkOption {
type = types.path;
default = "/var/lib/misc/dnsmasq.leases";
example = "/var/lib/dnsmasq/dnsmasq.leases";
description = lib.mdDoc ''
Path to the `dnsmasq.leases` file.
'';
};
};
serviceOpts = {
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-dnsmasq-exporter}/bin/dnsmasq_exporter \
--listen ${cfg.listenAddress}:${toString cfg.port} \
--dnsmasq ${cfg.dnsmasqListenAddress} \
--leases_path ${escapeShellArg cfg.leasesPath} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}