Merge pull request #91663 from mweinelt/kea-exporter

prometheus-kea-exporter: init at 0.4.1
This commit is contained in:
WilliButz 2021-05-14 14:38:08 +02:00 committed by GitHub
commit 94b2848559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 124 additions and 0 deletions

View File

@ -34,6 +34,7 @@ let
"fritzbox"
"json"
"jitsi"
"kea"
"keylight"
"knot"
"lnd"

View File

@ -0,0 +1,38 @@
{ config
, lib
, pkgs
, options
}:
with lib;
let
cfg = config.services.prometheus.exporters.kea;
in {
port = 9547;
extraOpts = {
controlSocketPaths = mkOption {
type = types.listOf types.str;
example = literalExample ''
[
"/run/kea/kea-dhcp4.socket"
"/run/kea/kea-dhcp6.socket"
]
'';
description = ''
Paths to kea control sockets
'';
};
};
serviceOpts = {
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-kea-exporter}/bin/kea-exporter \
--address ${cfg.listenAddress} \
--port ${toString cfg.port} \
${concatStringsSep " \\n" cfg.controlSocketPaths}
'';
SupplementaryGroups = [ "kea" ];
};
};
}

View File

@ -326,6 +326,57 @@ let
'';
};
kea = {
exporterConfig = {
enable = true;
controlSocketPaths = [
"/run/kea/kea-dhcp6.sock"
];
};
metricProvider = {
users.users.kea = {
isSystemUser = true;
};
users.groups.kea = {};
systemd.services.prometheus-kea-exporter.after = [ "kea-dhcp6.service" ];
systemd.services.kea-dhcp6 = let
configFile = pkgs.writeText "kea-dhcp6.conf" (builtins.toJSON {
Dhcp6 = {
"control-socket" = {
"socket-type" = "unix";
"socket-name" = "/run/kea/kea-dhcp6.sock";
};
};
});
in
{
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = false;
User = "kea";
Group = "kea";
ExecStart = "${pkgs.kea}/bin/kea-dhcp6 -c ${configFile}";
StateDirectory = "kea";
RuntimeDirectory = "kea";
UMask = "0007";
};
};
};
exporterTest = ''
wait_for_unit("kea-dhcp6.service")
wait_for_file("/run/kea/kea-dhcp6.sock")
wait_for_unit("prometheus-kea-exporter.service")
wait_for_open_port(9547)
succeed(
"curl --fail localhost:9547/metrics | grep 'packets_received_total'"
)
'';
};
knot = {
exporterConfig = {
enable = true;

View File

@ -0,0 +1,33 @@
{ lib, python3Packages, nixosTests }:
python3Packages.buildPythonApplication rec {
pname = "kea-exporter";
version = "0.4.2";
src = python3Packages.fetchPypi {
inherit pname version;
sha256 = "0dpzicv0ksyda2lprldkj452c23qycl5c9avca6x7f7rbqry9pnd";
};
propagatedBuildInputs = with python3Packages; [
click
prometheus_client
];
checkPhase = ''
$out/bin/kea-exporter --help > /dev/null
$out/bin/kea-exporter --version | grep -q ${version}
'';
passthru.tests = {
inherit (nixosTests.prometheus-exporters) kea;
};
meta = with lib; {
description = "Export Kea Metrics in the Prometheus Exposition Format";
homepage = "https://github.com/mweinelt/kea-exporter";
license = licenses.mit;
maintainers = with maintainers; [ hexa ];
};
}

View File

@ -19340,6 +19340,7 @@ in
prometheus-haproxy-exporter = callPackage ../servers/monitoring/prometheus/haproxy-exporter.nix { };
prometheus-jitsi-exporter = callPackage ../servers/monitoring/prometheus/jitsi-exporter.nix { };
prometheus-json-exporter = callPackage ../servers/monitoring/prometheus/json-exporter.nix { };
prometheus-kea-exporter = callPackage ../servers/monitoring/prometheus/kea-exporter.nix { };
prometheus-keylight-exporter = callPackage ../servers/monitoring/prometheus/keylight-exporter.nix { };
prometheus-knot-exporter = callPackage ../servers/monitoring/prometheus/knot-exporter.nix { };
prometheus-lnd-exporter = callPackage ../servers/monitoring/prometheus/lnd-exporter.nix { };