nixos/tests/prometheus-exporters.kea: init

This commit is contained in:
Martin Weinelt 2021-05-12 21:49:47 +02:00
parent bc4a80979b
commit dd7e1834ca
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
2 changed files with 56 additions and 1 deletions

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

@ -1,4 +1,4 @@
{ lib, python3Packages }:
{ lib, python3Packages, nixosTests }:
python3Packages.buildPythonApplication rec {
pname = "kea-exporter";
@ -19,6 +19,10 @@ python3Packages.buildPythonApplication rec {
$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";