nixos/prometheus/unifi-poller: rename to unpoller.

This commit is contained in:
Luke Granger-Brown 2022-11-24 15:30:34 +00:00
parent ffcd97b521
commit c7918fed9e
3 changed files with 17 additions and 12 deletions

View File

@ -73,7 +73,7 @@ let
"tor"
"unbound"
"unifi"
"unifi-poller"
"unpoller"
"v2ray"
"varnish"
"wireguard"
@ -230,6 +230,10 @@ in
options.services.prometheus.exporters = mkOption {
type = types.submodule {
options = (mkSubModules);
imports = [
../../../misc/assertions.nix
(lib.mkRenamedOptionModule [ "unifi-poller" ] [ "unpoller" ])
];
};
description = lib.mdDoc "Prometheus exporter configuration";
default = {};
@ -293,13 +297,14 @@ in
Please specify either 'services.prometheus.exporters.sql.configuration' or
'services.prometheus.exporters.sql.configFile'
'';
} ] ++ (flip map (attrNames cfg) (exporter: {
} ] ++ (flip map (attrNames exporterOpts) (exporter: {
assertion = cfg.${exporter}.firewallFilter != null -> cfg.${exporter}.openFirewall;
message = ''
The `firewallFilter'-option of exporter ${exporter} doesn't have any effect unless
`openFirewall' is set to `true'!
'';
}));
})) ++ config.services.prometheus.exporters.assertions;
warnings = config.services.prometheus.exporters.warnings;
}] ++ [(mkIf config.services.minio.enable {
services.prometheus.exporters.minio.minioAddress = mkDefault "http://localhost:9000";
services.prometheus.exporters.minio.minioAccessKey = mkDefault config.services.minio.accessKey;

View File

@ -3,9 +3,9 @@
with lib;
let
cfg = config.services.prometheus.exporters.unifi-poller;
cfg = config.services.prometheus.exporters.unpoller;
configFile = pkgs.writeText "prometheus-unifi-poller-exporter.json" (generators.toJSON {} {
configFile = pkgs.writeText "prometheus-unpoller-exporter.json" (generators.toJSON {} {
poller = { inherit (cfg.log) debug quiet; };
unifi = { inherit (cfg) controllers; };
influxdb.disable = true;
@ -21,8 +21,8 @@ in {
port = 9130;
extraOpts = {
inherit (options.services.unifi-poller.unifi) controllers;
inherit (options.services.unifi-poller) loki;
inherit (options.services.unpoller.unifi) controllers;
inherit (options.services.unpoller) loki;
log = {
debug = mkEnableOption (lib.mdDoc "debug logging including line numbers, high resolution timestamps, per-device logs.");
quiet = mkEnableOption (lib.mdDoc "startup and error logs only.");
@ -31,7 +31,7 @@ in {
};
serviceOpts.serviceConfig = {
ExecStart = "${pkgs.unifi-poller}/bin/unpoller --config ${configFile}";
ExecStart = "${pkgs.unpoller}/bin/unpoller --config ${configFile}";
DynamicUser = false;
};
}

View File

@ -1244,15 +1244,15 @@ let
'';
};
unifi-poller = {
nodeName = "unifi_poller";
unpoller = {
nodeName = "unpoller";
exporterConfig.enable = true;
exporterConfig.controllers = [{ }];
exporterTest = ''
wait_for_unit("prometheus-unifi-poller-exporter.service")
wait_for_unit("prometheus-unpoller-exporter.service")
wait_for_open_port(9130)
succeed(
"curl -sSf localhost:9130/metrics | grep 'unifipoller_build_info{.\\+} 1'"
"curl -sSf localhost:9130/metrics | grep 'unpoller_build_info{.\\+} 1'"
)
'';
};