about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/bird.nix
blob: 5f6c36f4c5671e50e202b21d4e509d1b28391331 (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
43
44
45
46
47
48
49
50
{ config, lib, pkgs, options }:

with lib;

let
  cfg = config.services.prometheus.exporters.bird;
in
{
  port = 9324;
  extraOpts = {
    birdVersion = mkOption {
      type = types.enum [ 1 2 ];
      default = 2;
      description = lib.mdDoc ''
        Specifies whether BIRD1 or BIRD2 is in use.
      '';
    };
    birdSocket = mkOption {
      type = types.path;
      default = "/run/bird/bird.ctl";
      description = lib.mdDoc ''
        Path to BIRD2 (or BIRD1 v4) socket.
      '';
    };
    newMetricFormat = mkOption {
      type = types.bool;
      default = true;
      description = lib.mdDoc ''
        Enable the new more-generic metric format.
      '';
    };
  };
  serviceOpts = {
    serviceConfig = {
      SupplementaryGroups = singleton (if cfg.birdVersion == 1 then "bird" else "bird2");
      ExecStart = ''
        ${pkgs.prometheus-bird-exporter}/bin/bird_exporter \
          -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
          -bird.socket ${cfg.birdSocket} \
          -bird.v2=${if cfg.birdVersion == 2 then "true" else "false"} \
          -format.new=${if cfg.newMetricFormat then "true" else "false"} \
          ${concatStringsSep " \\\n  " cfg.extraFlags}
      '';
      RestrictAddressFamilies = [
        # Need AF_UNIX to collect data
        "AF_UNIX"
      ];
    };
  };
}