diff --git a/nixos/tests/kea.nix b/nixos/tests/kea.nix index c8ecf771fa13..98a8e93a0760 100644 --- a/nixos/tests/kea.nix +++ b/nixos/tests/kea.nix @@ -44,6 +44,11 @@ import ./make-test-python.nix ({ pkgs, lib, ...}: { name = "/var/lib/kea/dhcp4.leases"; }; + control-socket = { + socket-type = "unix"; + socket-name = "/run/kea/dhcp4.sock"; + }; + interfaces-config = { dhcp-socket-type = "raw"; interfaces = [ @@ -89,6 +94,25 @@ import ./make-test-python.nix ({ pkgs, lib, ...}: { }; }; }; + + services.kea.ctrl-agent = { + enable = true; + settings = { + http-host = "127.0.0.1"; + http-port = 8000; + control-sockets.dhcp4 = { + socket-type = "unix"; + socket-name = "/run/kea/dhcp4.sock"; + }; + }; + }; + + services.prometheus.exporters.kea = { + enable = true; + controlSocketPaths = [ + "http://127.0.0.1:8000" + ]; + }; }; nameserver = { config, pkgs, ... }: { @@ -182,5 +206,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...}: { client.wait_until_succeeds("ping -c 5 10.0.0.1") router.wait_until_succeeds("ping -c 5 10.0.0.3") nameserver.wait_until_succeeds("kdig +short client.lan.nixos.test @10.0.0.2 | grep -q 10.0.0.3") + router.log(router.execute("curl 127.0.0.1:9547")[1]) + router.succeed("curl --no-buffer 127.0.0.1:9547 | grep -qE '^kea_dhcp4_addresses_assigned_total.*1.0$'") ''; }) diff --git a/pkgs/servers/monitoring/prometheus/kea-exporter.nix b/pkgs/servers/monitoring/prometheus/kea-exporter.nix index e18e1fba4bf1..f4965bd54fa8 100644 --- a/pkgs/servers/monitoring/prometheus/kea-exporter.nix +++ b/pkgs/servers/monitoring/prometheus/kea-exporter.nix @@ -1,6 +1,7 @@ { lib , python3Packages , fetchPypi +, nixosTests }: python3Packages.buildPythonApplication rec { @@ -29,6 +30,10 @@ python3Packages.buildPythonApplication rec { $out/bin/kea-exporter --version | grep -q ${version} ''; + passthru.tests = { + inherit (nixosTests) kea; + }; + meta = with lib; { changelog = "https://github.com/mweinelt/kea-exporter/blob/v${version}/HISTORY"; description = "Export Kea Metrics in the Prometheus Exposition Format";