Merge pull request #297622 from mweinelt/kea-exporter-0.7.0

kea-exporter: 0.6.1 -> 0.7.0
This commit is contained in:
Martin Weinelt 2024-03-21 14:29:42 +01:00 committed by GitHub
commit 3b7d9c77b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
74 changed files with 114 additions and 128 deletions

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, options, ... }:
{ config, pkgs, lib, options, utils, ... }:
let
inherit (lib) concatStrings foldl foldl' genAttrs literalExpression maintainers
@ -94,10 +94,10 @@ let
"zfs"
]
(name:
import (./. + "/exporters/${name}.nix") { inherit config lib pkgs options; }
import (./. + "/exporters/${name}.nix") { inherit config lib pkgs options utils; }
)) // (mapAttrs
(name: params:
import (./. + "/exporters/${params.name}.nix") { inherit config lib pkgs options; type = params.type ; })
import (./. + "/exporters/${params.name}.nix") { inherit config lib pkgs options utils; type = params.type ; })
{
exportarr-bazarr = {
name = "exportarr";

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options, type }:
{ config, lib, pkgs, options, type, ... }:
let
cfg = config.services.prometheus.exporters."exportarr-${type}";

View file

@ -2,6 +2,7 @@
, lib
, pkgs
, options
, ...
}:
let

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
let
cfg = config.services.prometheus.exporters.graphite;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;
let

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,7 +1,8 @@
{ config
, lib
, pkgs
, options
, utils
, ...
}:
with lib;
@ -9,18 +10,22 @@ with lib;
let
cfg = config.services.prometheus.exporters.kea;
in {
imports = [
(mkRenamedOptionModule [ "controlSocketPaths" ] [ "targets" ])
];
port = 9547;
extraOpts = {
controlSocketPaths = mkOption {
targets = mkOption {
type = types.listOf types.str;
example = literalExpression ''
[
"/run/kea/kea-dhcp4.socket"
"/run/kea/kea-dhcp6.socket"
"http://127.0.0.1:8547"
]
'';
description = lib.mdDoc ''
Paths to kea control sockets
Paths or URLs to the Kea control socket.
'';
};
};
@ -32,12 +37,11 @@ in {
serviceConfig = {
User = "kea";
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-kea-exporter}/bin/kea-exporter \
--address ${cfg.listenAddress} \
--port ${toString cfg.port} \
${concatStringsSep " " cfg.controlSocketPaths}
'';
ExecStart = utils.escapeSystemdExecArgs ([
(lib.getExe pkgs.prometheus-kea-exporter)
"--address" cfg.listenAddress
"--port" cfg.port
] ++ cfg.extraFlags ++ cfg.targets);
RuntimeDirectory = "kea";
RuntimeDirectoryPreserve = true;
RestrictAddressFamilies = [

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
let
cfg = config.services.prometheus.exporters.mysqld;
inherit (lib) types mkOption mdDoc mkIf mkForce cli concatStringsSep optionalString escapeShellArgs;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -2,6 +2,7 @@
, lib
, pkgs
, options
, ...
}:
let

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;
let

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
let
cfg = config.services.prometheus.exporters.rtl_433;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
let
inherit (lib) mkOption types;

View file

@ -2,6 +2,7 @@
, lib
, pkgs
, options
, ...
}:
let

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.sql;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -2,6 +2,7 @@
, lib
, pkgs
, options
, ...
}:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, options }:
{ config, lib, pkgs, options, ... }:
with lib;

View file

@ -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$'")
'';
})

View file

@ -418,54 +418,6 @@ let
'';
};
kea = let
controlSocketPathV4 = "/run/kea/dhcp4.sock";
controlSocketPathV6 = "/run/kea/dhcp6.sock";
in
{
exporterConfig = {
enable = true;
controlSocketPaths = [
controlSocketPathV4
controlSocketPathV6
];
};
metricProvider = {
services.kea = {
dhcp4 = {
enable = true;
settings = {
control-socket = {
socket-type = "unix";
socket-name = controlSocketPathV4;
};
};
};
dhcp6 = {
enable = true;
settings = {
control-socket = {
socket-type = "unix";
socket-name = controlSocketPathV6;
};
};
};
};
};
exporterTest = ''
wait_for_unit("kea-dhcp4-server.service")
wait_for_unit("kea-dhcp6-server.service")
wait_for_file("${controlSocketPathV4}")
wait_for_file("${controlSocketPathV6}")
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

@ -6,13 +6,13 @@
python3Packages.buildPythonApplication rec {
pname = "kea-exporter";
version = "0.6.1";
version = "0.7.0";
format = "pyproject";
src = fetchPypi {
pname = "kea_exporter";
inherit version;
hash = "sha256-PyNFSTDqT+PBY7d9NSG1FVhN+Y3ID13T6859kBYsFzU=";
hash = "sha256-kn2iwYWcyW90tgfWmzLF7rU06fJyLRzqYKNLOgu/Yqk=";
};
nativeBuildInputs = with python3Packages; [
@ -31,7 +31,7 @@ python3Packages.buildPythonApplication rec {
'';
passthru.tests = {
inherit (nixosTests.prometheus-exporters) kea;
inherit (nixosTests) kea;
};
meta = with lib; {