1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9 cfg = config.services.prometheus.exporters.frr;
10 inherit (lib)
11 mkOption
12 types
13 concatStringsSep
14 concatMapStringsSep
15 ;
16in
17{
18 port = 9342;
19 extraOpts = {
20 user = mkOption {
21 type = types.str;
22 default = "frr";
23 description = ''
24 User name under which the frr exporter shall be run.
25 The exporter talks to frr using a unix socket, which is owned by frr.
26 '';
27 };
28 group = mkOption {
29 type = types.str;
30 default = "frrtty";
31 description = ''
32 Group under which the frr exporter shall be run.
33 The exporter talks to frr using a unix socket, which is owned by frrtty group.
34 '';
35 };
36 enabledCollectors = mkOption {
37 type = types.listOf types.str;
38 default = [ ];
39 example = [ "vrrp" ];
40 description = ''
41 Collectors to enable. The collectors listed here are enabled in addition to the default ones.
42 '';
43 };
44 disabledCollectors = mkOption {
45 type = types.listOf types.str;
46 default = [ ];
47 example = [ "bfd" ];
48 description = ''
49 Collectors to disable which are enabled by default.
50 '';
51 };
52 };
53 serviceOpts = {
54 serviceConfig = {
55 DynamicUser = false;
56 RuntimeDirectory = "prometheus-frr-exporter";
57 RestrictAddressFamilies = [ "AF_UNIX" ];
58 ExecStart = ''
59 ${lib.getExe pkgs.prometheus-frr-exporter} \
60 ${concatMapStringsSep " " (x: "--collector." + x) cfg.enabledCollectors} \
61 ${concatMapStringsSep " " (x: "--no-collector." + x) cfg.disabledCollectors} \
62 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} ${concatStringsSep " " cfg.extraFlags}
63 '';
64 };
65 };
66}