diff options
author | Martin Weinelt <hexa@darmstadt.ccc.de> | 2021-05-12 21:49:47 +0200 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2021-05-14 14:09:19 +0200 |
commit | dd7e1834ca455d9843d2b54f425ad1243322068f (patch) | |
tree | eaa4c8585948f4dccc9593e71610e498dd653f70 | |
parent | bc4a80979bbf71aaae67682c91b41e300b919b66 (diff) |
nixos/tests/prometheus-exporters.kea: init
-rw-r--r-- | nixos/tests/prometheus-exporters.nix | 51 | ||||
-rw-r--r-- | pkgs/servers/monitoring/prometheus/kea-exporter.nix | 6 |
2 files changed, 56 insertions, 1 deletions
diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix index 2b17d0ff78ff9..67ebb5e2921e5 100644 --- a/nixos/tests/prometheus-exporters.nix +++ b/nixos/tests/prometheus-exporters.nix @@ -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; diff --git a/pkgs/servers/monitoring/prometheus/kea-exporter.nix b/pkgs/servers/monitoring/prometheus/kea-exporter.nix index cffa2e6fab474..1f5ff7c02235b 100644 --- a/pkgs/servers/monitoring/prometheus/kea-exporter.nix +++ b/pkgs/servers/monitoring/prometheus/kea-exporter.nix @@ -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"; |