1{ config
2, lib
3, pkgs
4, options
5}:
6
7with lib;
8
9let
10 cfg = config.services.prometheus.exporters.kea;
11in {
12 port = 9547;
13 extraOpts = {
14 controlSocketPaths = mkOption {
15 type = types.listOf types.str;
16 example = literalExpression ''
17 [
18 "/run/kea-dhcp4/kea-dhcp4.socket"
19 "/run/kea-dhcp6/kea-dhcp6.socket"
20 ]
21 '';
22 description = lib.mdDoc ''
23 Paths to kea control sockets
24 '';
25 };
26 };
27 serviceOpts = {
28 after = [
29 "kea-dhcp4-server.service"
30 "kea-dhcp6-server.service"
31 ];
32 serviceConfig = {
33 User = "kea";
34 ExecStart = ''
35 ${pkgs.prometheus-kea-exporter}/bin/kea-exporter \
36 --address ${cfg.listenAddress} \
37 --port ${toString cfg.port} \
38 ${concatStringsSep " " cfg.controlSocketPaths}
39 '';
40 SupplementaryGroups = [ "kea" ];
41 RestrictAddressFamilies = [
42 # Need AF_UNIX to collect data
43 "AF_UNIX"
44 ];
45 };
46 };
47}