Merge pull request #214809 from drupol/fix/update-pihole-exporter

fix: `pihole-exporter` NixOS module
This commit is contained in:
Nick Cao 2023-02-06 18:37:11 +08:00 committed by GitHub
commit 701390c82b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 16 deletions

View file

@ -887,6 +887,13 @@
been fixed to allow more than one plugin in the path. been fixed to allow more than one plugin in the path.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
The option
<literal>services.prometheus.exporters.pihole.interval</literal>
does not exist anymore and has been removed.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</section> </section>
</section> </section>

View file

@ -220,3 +220,5 @@ In addition to numerous new and upgraded packages, this release has the followin
- `nixos-version` now accepts `--configuration-revision` to display more information about the current generation revision - `nixos-version` now accepts `--configuration-revision` to display more information about the current generation revision
- The option `services.nomad.extraSettingsPlugins` has been fixed to allow more than one plugin in the path. - The option `services.nomad.extraSettingsPlugins` has been fixed to allow more than one plugin in the path.
- The option `services.prometheus.exporters.pihole.interval` does not exist anymore and has been removed.

View file

@ -6,6 +6,11 @@ let
cfg = config.services.prometheus.exporters.pihole; cfg = config.services.prometheus.exporters.pihole;
in in
{ {
imports = [
(mkRemovedOptionModule [ "interval"] "This option has been removed.")
({ options.warnings = options.warnings; options.assertions = options.assertions; })
];
port = 9617; port = 9617;
extraOpts = { extraOpts = {
apiToken = mkOption { apiToken = mkOption {
@ -13,15 +18,7 @@ in
default = ""; default = "";
example = "580a770cb40511eb85290242ac130003580a770cb40511eb85290242ac130003"; example = "580a770cb40511eb85290242ac130003580a770cb40511eb85290242ac130003";
description = lib.mdDoc '' description = lib.mdDoc ''
pi-hole API token which can be used instead of a password Pi-Hole API token which can be used instead of a password
'';
};
interval = mkOption {
type = types.str;
default = "10s";
example = "30s";
description = lib.mdDoc ''
How often to scrape new data
''; '';
}; };
password = mkOption { password = mkOption {
@ -29,7 +26,7 @@ in
default = ""; default = "";
example = "password"; example = "password";
description = lib.mdDoc '' description = lib.mdDoc ''
The password to login into pihole. An api token can be used instead. The password to login into Pi-Hole. An api token can be used instead.
''; '';
}; };
piholeHostname = mkOption { piholeHostname = mkOption {
@ -37,7 +34,7 @@ in
default = "pihole"; default = "pihole";
example = "127.0.0.1"; example = "127.0.0.1";
description = lib.mdDoc '' description = lib.mdDoc ''
Hostname or address where to find the pihole webinterface Hostname or address where to find the Pi-Hole webinterface
''; '';
}; };
piholePort = mkOption { piholePort = mkOption {
@ -45,7 +42,7 @@ in
default = 80; default = 80;
example = 443; example = 443;
description = lib.mdDoc '' description = lib.mdDoc ''
The port pihole webinterface is reachable on The port Pi-Hole webinterface is reachable on
''; '';
}; };
protocol = mkOption { protocol = mkOption {
@ -53,21 +50,28 @@ in
default = "http"; default = "http";
example = "https"; example = "https";
description = lib.mdDoc '' description = lib.mdDoc ''
The protocol which is used to connect to pihole The protocol which is used to connect to Pi-Hole
'';
};
timeout = mkOption {
type = types.str;
default = "5s";
description = lib.mdDoc ''
Controls the timeout to connect to a Pi-Hole instance
''; '';
}; };
}; };
serviceOpts = { serviceOpts = {
serviceConfig = { serviceConfig = {
ExecStart = '' ExecStart = ''
${pkgs.bash}/bin/bash -c "${pkgs.prometheus-pihole-exporter}/bin/pihole-exporter \ ${pkgs.prometheus-pihole-exporter}/bin/pihole-exporter \
-interval ${cfg.interval} \
${optionalString (cfg.apiToken != "") "-pihole_api_token ${cfg.apiToken}"} \ ${optionalString (cfg.apiToken != "") "-pihole_api_token ${cfg.apiToken}"} \
-pihole_hostname ${cfg.piholeHostname} \ -pihole_hostname ${cfg.piholeHostname} \
${optionalString (cfg.password != "") "-pihole_password ${cfg.password}"} \ ${optionalString (cfg.password != "") "-pihole_password ${cfg.password}"} \
-pihole_port ${toString cfg.piholePort} \ -pihole_port ${toString cfg.piholePort} \
-pihole_protocol ${cfg.protocol} \ -pihole_protocol ${cfg.protocol} \
-port ${toString cfg.port}" -port ${toString cfg.port} \
-timeout ${cfg.timeout}
''; '';
}; };
}; };