about summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/prometheus/exporters/dnsmasq.nix
blob: ba438ea74a3b6f035d65047dcabb582dda396020 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ config, lib, pkgs, options, ... }:

let
  cfg = config.services.prometheus.exporters.dnsmasq;
  inherit (lib)
    mkOption
    types
    concatStringsSep
    escapeShellArg
    ;
in
{
  port = 9153;
  extraOpts = {
    dnsmasqListenAddress = mkOption {
      type = types.str;
      default = "localhost:53";
      description = ''
        Address on which dnsmasq listens.
      '';
    };
    leasesPath = mkOption {
      type = types.path;
      default = "/var/lib/misc/dnsmasq.leases";
      example = "/var/lib/dnsmasq/dnsmasq.leases";
      description = ''
        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}
      '';
    };
  };
}