1 { config, lib, pkgs, ... }:
5 maintainers types mkEnableOption mkOption mkIf
6 literalExpression escapeShellArg escapeShellArgs;
7 cfg = config.services.mtr-exporter;
12 enable = mkEnableOption (lib.mdDoc "a Prometheus exporter for MTR");
16 example = "example.org";
17 description = lib.mdDoc "Target to check using MTR.";
23 description = lib.mdDoc "Interval between MTR checks in seconds.";
29 description = lib.mdDoc "Listen port for MTR exporter.";
34 default = "127.0.0.1";
35 description = lib.mdDoc "Listen address for MTR exporter.";
39 type = with types; listOf str;
42 description = lib.mdDoc "Additional flags to pass to MTR.";
48 config = mkIf cfg.enable {
49 systemd.services.mtr-exporter = {
51 exec ${pkgs.mtr-exporter}/bin/mtr-exporter \
52 -mtr ${pkgs.mtr}/bin/mtr \
53 -schedule '@every ${toString cfg.interval}s' \
54 -bind ${escapeShellArg cfg.address}:${toString cfg.port} \
56 ${escapeShellArgs (cfg.mtrFlags ++ [ cfg.target ])}
58 wantedBy = [ "multi-user.target" ];
59 requires = [ "network.target" ];
60 after = [ "network.target" ];
62 Restart = "on-failure";
64 CapabilityBoundingSet = [ "" ];
66 LockPersonality = true;
68 PrivateDevices = true;
72 ProtectControlGroups = true;
74 ProtectHostname = true;
75 ProtectKernelLogs = true;
76 ProtectKernelModules = true;
77 ProtectKernelTunables = true;
78 ProtectProc = "invisible";
79 ProtectSystem = "strict";
80 RestrictNamespaces = true;
81 RestrictRealtime = true;
86 meta.maintainers = with maintainers; [ jakubgs ];