mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-20 00:19:25 +03:00

Fixes race conditions like this: > systemd[1]: Started prometheus-kea-exporter.service. > kea-exporter[927]: Listening on http://0.0.0.0:9547 > kea-exporter[927]: Socket at /run/kea/dhcp4.sock does not exist. Is Kea running? > systemd[1]: prometheus-kea-exporter.service: Main process exited, code=exited, status=1/FAILURE
47 lines
968 B
Nix
47 lines
968 B
Nix
{ config
|
|
, lib
|
|
, pkgs
|
|
, options
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.prometheus.exporters.kea;
|
|
in {
|
|
port = 9547;
|
|
extraOpts = {
|
|
controlSocketPaths = mkOption {
|
|
type = types.listOf types.str;
|
|
example = literalExpression ''
|
|
[
|
|
"/run/kea/kea-dhcp4.socket"
|
|
"/run/kea/kea-dhcp6.socket"
|
|
]
|
|
'';
|
|
description = ''
|
|
Paths to kea control sockets
|
|
'';
|
|
};
|
|
};
|
|
serviceOpts = {
|
|
after = [
|
|
"kea-dhcp4-server.service"
|
|
"kea-dhcp6-server.service"
|
|
];
|
|
serviceConfig = {
|
|
User = "kea";
|
|
ExecStart = ''
|
|
${pkgs.prometheus-kea-exporter}/bin/kea-exporter \
|
|
--address ${cfg.listenAddress} \
|
|
--port ${toString cfg.port} \
|
|
${concatStringsSep " \\n" cfg.controlSocketPaths}
|
|
'';
|
|
SupplementaryGroups = [ "kea" ];
|
|
RestrictAddressFamilies = [
|
|
# Need AF_UNIX to collect data
|
|
"AF_UNIX"
|
|
];
|
|
};
|
|
};
|
|
}
|