1{ config, lib, pkgs }:
2
3with lib;
4
5let
6 cfg = config.services.prometheus.exporters.dnsmasq;
7in
8{
9 port = 9153;
10 extraOpts = {
11 dnsmasqListenAddress = mkOption {
12 type = types.str;
13 default = "localhost:53";
14 description = ''
15 Address on which dnsmasq listens.
16 '';
17 };
18 leasesPath = mkOption {
19 type = types.path;
20 default = "/var/lib/misc/dnsmasq.leases";
21 example = "/var/lib/dnsmasq/dnsmasq.leases";
22 description = ''
23 Path to the <literal>dnsmasq.leases</literal> file.
24 '';
25 };
26 };
27 serviceOpts = {
28 serviceConfig = {
29 DynamicUser = true;
30 ExecStart = ''
31 ${pkgs.prometheus-dnsmasq-exporter}/bin/dnsmasq_exporter \
32 --listen ${cfg.listenAddress}:${toString cfg.port} \
33 --dnsmasq ${cfg.dnsmasqListenAddress} \
34 --leases_path ${cfg.leasesPath} \
35 ${concatStringsSep " \\\n " cfg.extraFlags}
36 '';
37 };
38 };
39}