1{ config, lib, pkgs, options }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.knot; 7in { 8 port = 9433; 9 extraOpts = { 10 knotLibraryPath = mkOption { 11 type = types.nullOr types.str; 12 default = null; 13 example = literalExpression ''"''${pkgs.knot-dns.out}/lib/libknot.so"''; 14 description = lib.mdDoc '' 15 Path to the library of `knot-dns`. 16 ''; 17 }; 18 19 knotSocketPath = mkOption { 20 type = types.str; 21 default = "/run/knot/knot.sock"; 22 description = lib.mdDoc '' 23 Socket path of {manpage}`knotd(8)`. 24 ''; 25 }; 26 27 knotSocketTimeout = mkOption { 28 type = types.ints.positive; 29 default = 2000; 30 description = lib.mdDoc '' 31 Timeout in seconds. 32 ''; 33 }; 34 }; 35 serviceOpts = { 36 path = with pkgs; [ 37 procps 38 ]; 39 serviceConfig = { 40 ExecStart = '' 41 ${pkgs.prometheus-knot-exporter}/bin/knot-exporter \ 42 --web-listen-addr ${cfg.listenAddress} \ 43 --web-listen-port ${toString cfg.port} \ 44 --knot-socket-path ${cfg.knotSocketPath} \ 45 --knot-socket-timeout ${toString cfg.knotSocketTimeout} \ 46 ${lib.optionalString (cfg.knotLibraryPath != null) "--knot-library-path ${cfg.knotLibraryPath}"} \ 47 ${concatStringsSep " \\\n " cfg.extraFlags} 48 ''; 49 SupplementaryGroups = [ 50 "knot" 51 ]; 52 RestrictAddressFamilies = [ 53 # Need AF_UNIX to collect data 54 "AF_UNIX" 55 ]; 56 }; 57 }; 58}