mtr-exporter: init at 0.1.0 (3ce854a5)
This is a useful utility for monitoring network performance over time using a combination of MTR and Prometheus. Also adding a service definition. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
d856f24d3c
commit
7d988867ff
6 changed files with 124 additions and 0 deletions
|
@ -96,6 +96,13 @@
|
|||
<link xlink:href="options.html#opt-services.maddy.enable">services.maddy</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link xlink:href="https://github.com/mgumz/mtr-exporter">mtr-exporter</link>,
|
||||
a Prometheus exporter for mtr metrics. Available as
|
||||
<link xlink:href="options.html#opt-services.mtr-exporter.enable">services.mtr-exporter</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link xlink:href="https://tetrd.app">tetrd</link>, share your
|
||||
|
|
|
@ -31,6 +31,8 @@ In addition to numerous new and upgraded packages, this release has the followin
|
|||
|
||||
- [maddy](https://maddy.email), a composable all-in-one mail server. Available as [services.maddy](options.html#opt-services.maddy.enable).
|
||||
|
||||
- [mtr-exporter](https://github.com/mgumz/mtr-exporter), a Prometheus exporter for mtr metrics. Available as [services.mtr-exporter](options.html#opt-services.mtr-exporter.enable).
|
||||
|
||||
- [tetrd](https://tetrd.app), share your internet connection from your device to your PC and vice versa through a USB cable. Available at [services.tetrd](#opt-services.tetrd.enable).
|
||||
|
||||
## Backward Incompatibilities {#sec-release-22.05-incompatibilities}
|
||||
|
|
|
@ -797,6 +797,7 @@
|
|||
./services/networking/miredo.nix
|
||||
./services/networking/mstpd.nix
|
||||
./services/networking/mtprotoproxy.nix
|
||||
./services/networking/mtr-exporter.nix
|
||||
./services/networking/mullvad-vpn.nix
|
||||
./services/networking/multipath.nix
|
||||
./services/networking/murmur.nix
|
||||
|
|
87
nixos/modules/services/networking/mtr-exporter.nix
Normal file
87
nixos/modules/services/networking/mtr-exporter.nix
Normal file
|
@ -0,0 +1,87 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
maintainers types mkEnableOption mkOption mkIf
|
||||
literalExpression escapeShellArg escapeShellArgs;
|
||||
cfg = config.services.mtr-exporter;
|
||||
in {
|
||||
options = {
|
||||
services = {
|
||||
mtr-exporter = {
|
||||
enable = mkEnableOption "a Prometheus exporter for MTR";
|
||||
|
||||
target = mkOption {
|
||||
type = types.str;
|
||||
example = "example.org";
|
||||
description = "Target to check using MTR.";
|
||||
};
|
||||
|
||||
interval = mkOption {
|
||||
type = types.int;
|
||||
default = 60;
|
||||
description = "Interval between MTR checks in seconds.";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 8080;
|
||||
description = "Listen port for MTR exporter.";
|
||||
};
|
||||
|
||||
address = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1";
|
||||
description = "Listen address for MTR exporter.";
|
||||
};
|
||||
|
||||
mtrFlags = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [];
|
||||
example = ["-G1"];
|
||||
description = "Additional flags to pass to MTR.";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.mtr-exporter = {
|
||||
script = ''
|
||||
exec ${pkgs.mtr-exporter}/bin/mtr-exporter \
|
||||
-mtr ${pkgs.mtr}/bin/mtr \
|
||||
-schedule '@every ${toString cfg.interval}s' \
|
||||
-bind ${escapeShellArg cfg.address}:${toString cfg.port} \
|
||||
-- \
|
||||
${escapeShellArgs (cfg.mtrFlags ++ [ cfg.target ])}
|
||||
'';
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
requires = [ "network.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
Restart = "on-failure";
|
||||
# Hardening
|
||||
CapabilityBoundingSet = [ "" ];
|
||||
DynamicUser = true;
|
||||
LockPersonality = true;
|
||||
ProcSubset = "pid";
|
||||
PrivateDevices = true;
|
||||
PrivateUsers = true;
|
||||
PrivateTmp = true;
|
||||
ProtectClock = true;
|
||||
ProtectControlGroups = true;
|
||||
ProtectHome = true;
|
||||
ProtectHostname = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectProc = "invisible";
|
||||
ProtectSystem = "strict";
|
||||
RestrictNamespaces = true;
|
||||
RestrictRealtime = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
meta.maintainers = with maintainers; [ jakubgs ];
|
||||
}
|
25
pkgs/tools/networking/mtr-exporter/default.nix
Normal file
25
pkgs/tools/networking/mtr-exporter/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ lib, buildGoModule, fetchurl, fetchFromGitHub }:
|
||||
|
||||
buildGoModule rec {
|
||||
pname = "mtr-exporter";
|
||||
version = "0.1.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "mgumz";
|
||||
repo = "mtr-exporter";
|
||||
rev = "3ce854a53a44780d2294f59284d21b06aeae6940";
|
||||
sha256 = "sha256-PZCSuvtTBD7yoUE1fR9Z/u3aa1BZgbrcj18smnWRYf4=";
|
||||
};
|
||||
|
||||
vendorSha256 = "0njn0ac7j3lv8ax6jc3bg3hh96a42jal212qk6zxrd46nb5l1rj8";
|
||||
|
||||
meta = with lib; {
|
||||
description = ''
|
||||
Mtr-exporter periodically executes mtr to a given host and
|
||||
provides the measured results as prometheus metrics.
|
||||
'';
|
||||
homepage = "https://github.com/mgumz/mtr-exporter";
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ jakubgs ];
|
||||
};
|
||||
}
|
|
@ -7867,6 +7867,8 @@ with pkgs;
|
|||
|
||||
mtr = callPackage ../tools/networking/mtr {};
|
||||
|
||||
mtr-exporter = callPackage ../tools/networking/mtr-exporter {};
|
||||
|
||||
mtr-gui = callPackage ../tools/networking/mtr { withGtk = true; };
|
||||
|
||||
mtx = callPackage ../tools/backup/mtx {};
|
||||
|
|
Loading…
Reference in a new issue