1{ config, lib, pkgs, options }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.bird; 7in 8{ 9 port = 9324; 10 extraOpts = { 11 birdVersion = mkOption { 12 type = types.enum [ 1 2 ]; 13 default = 2; 14 description = lib.mdDoc '' 15 Specifies whether BIRD1 or BIRD2 is in use. 16 ''; 17 }; 18 birdSocket = mkOption { 19 type = types.path; 20 default = "/run/bird/bird.ctl"; 21 description = lib.mdDoc '' 22 Path to BIRD2 (or BIRD1 v4) socket. 23 ''; 24 }; 25 newMetricFormat = mkOption { 26 type = types.bool; 27 default = true; 28 description = lib.mdDoc '' 29 Enable the new more-generic metric format. 30 ''; 31 }; 32 }; 33 serviceOpts = { 34 serviceConfig = { 35 SupplementaryGroups = singleton (if cfg.birdVersion == 1 then "bird" else "bird2"); 36 ExecStart = '' 37 ${pkgs.prometheus-bird-exporter}/bin/bird_exporter \ 38 -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ 39 -bird.socket ${cfg.birdSocket} \ 40 -bird.v2=${if cfg.birdVersion == 2 then "true" else "false"} \ 41 -format.new=${if cfg.newMetricFormat then "true" else "false"} \ 42 ${concatStringsSep " \\\n " cfg.extraFlags} 43 ''; 44 RestrictAddressFamilies = [ 45 # Need AF_UNIX to collect data 46 "AF_UNIX" 47 ]; 48 }; 49 }; 50}