diff --git a/nixos/tests/kea.nix b/nixos/tests/kea.nix index e339c4cc7000..ec249f0c7150 100644 --- a/nixos/tests/kea.nix +++ b/nixos/tests/kea.nix @@ -110,6 +110,13 @@ }; }; }; + + services.prometheus.exporters.kea = { + enable = true; + controlSocketPaths = [ + config.services.kea.dhcp4.settings.control-socket.socket-name + ]; + }; }; nameserver = @@ -217,5 +224,9 @@ with subtest("DDNS"): nameserver.wait_until_succeeds("kdig +short client.lan.nixos.test @10.0.0.2 | grep -q 10.0.0.3") + + with subtest("Prometheus Exporter"): + router.log(router.execute("curl 127.0.0.1:9547")[1]) + router.succeed("curl --silent 127.0.0.1:9547 | grep -qE '^kea_dhcp4_addresses_assigned_total.*1.0$'") ''; } diff --git a/pkgs/by-name/pr/prometheus-kea-exporter/package.nix b/pkgs/by-name/pr/prometheus-kea-exporter/package.nix index 2b2cadba9b01..dc9c463886a0 100644 --- a/pkgs/by-name/pr/prometheus-kea-exporter/package.nix +++ b/pkgs/by-name/pr/prometheus-kea-exporter/package.nix @@ -1,19 +1,21 @@ { lib, python3Packages, - fetchPypi, + fetchFromGitHub, nixosTests, + versionCheckHook, }: -python3Packages.buildPythonApplication rec { +python3Packages.buildPythonApplication (finalAttrs: { pname = "kea-exporter"; - version = "0.7.0"; + version = "0.7.1"; pyproject = true; - src = fetchPypi { - pname = "kea_exporter"; - inherit version; - hash = "sha256-kn2iwYWcyW90tgfWmzLF7rU06fJyLRzqYKNLOgu/Yqk="; + src = fetchFromGitHub { + owner = "mweinelt"; + repo = "kea-exporter"; + tag = "v${finalAttrs.version}"; + hash = "sha256-UwQYR01cBdPEUBhOo5TqwmptAvJpxln1OLU2boAFdn4="; }; nativeBuildInputs = with python3Packages; [ @@ -26,21 +28,17 @@ python3Packages.buildPythonApplication rec { requests ]; - checkPhase = '' - $out/bin/kea-exporter --help > /dev/null - $out/bin/kea-exporter --version | grep -q ${version} - ''; - + nativeInstallCheckInputs = [ versionCheckHook ]; passthru.tests = { inherit (nixosTests) kea; }; meta = { - changelog = "https://github.com/mweinelt/kea-exporter/blob/v${version}/HISTORY"; + changelog = "https://github.com/mweinelt/kea-exporter/blob/v${finalAttrs.version}/HISTORY"; description = "Export Kea Metrics in the Prometheus Exposition Format"; mainProgram = "kea-exporter"; homepage = "https://github.com/mweinelt/kea-exporter"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ hexa ]; }; -} +})