Merge pull request #91663 from mweinelt/kea-exporter
prometheus-kea-exporter: init at 0.4.1
This commit is contained in:
commit
94b2848559
|
@ -34,6 +34,7 @@ let
|
||||||
"fritzbox"
|
"fritzbox"
|
||||||
"json"
|
"json"
|
||||||
"jitsi"
|
"jitsi"
|
||||||
|
"kea"
|
||||||
"keylight"
|
"keylight"
|
||||||
"knot"
|
"knot"
|
||||||
"lnd"
|
"lnd"
|
||||||
|
|
|
@ -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" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -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 = {
|
knot = {
|
||||||
exporterConfig = {
|
exporterConfig = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
33
pkgs/servers/monitoring/prometheus/kea-exporter.nix
Normal file
33
pkgs/servers/monitoring/prometheus/kea-exporter.nix
Normal 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 ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -19340,6 +19340,7 @@ in
|
||||||
prometheus-haproxy-exporter = callPackage ../servers/monitoring/prometheus/haproxy-exporter.nix { };
|
prometheus-haproxy-exporter = callPackage ../servers/monitoring/prometheus/haproxy-exporter.nix { };
|
||||||
prometheus-jitsi-exporter = callPackage ../servers/monitoring/prometheus/jitsi-exporter.nix { };
|
prometheus-jitsi-exporter = callPackage ../servers/monitoring/prometheus/jitsi-exporter.nix { };
|
||||||
prometheus-json-exporter = callPackage ../servers/monitoring/prometheus/json-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-keylight-exporter = callPackage ../servers/monitoring/prometheus/keylight-exporter.nix { };
|
||||||
prometheus-knot-exporter = callPackage ../servers/monitoring/prometheus/knot-exporter.nix { };
|
prometheus-knot-exporter = callPackage ../servers/monitoring/prometheus/knot-exporter.nix { };
|
||||||
prometheus-lnd-exporter = callPackage ../servers/monitoring/prometheus/lnd-exporter.nix { };
|
prometheus-lnd-exporter = callPackage ../servers/monitoring/prometheus/lnd-exporter.nix { };
|
||||||
|
|
Loading…
Reference in a new issue