Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pihole-exporter NixOS module #214809

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nixos/doc/manual/from_md/release-notes/rl-2305.section.xml
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,13 @@
been fixed to allow more than one plugin in the path.
</para>
</listitem>
<listitem>
<para>
The option
<literal>services.prometheus.exporters.pihole.interval</literal>
does not exist anymore and has been removed.
</para>
</listitem>
</itemizedlist>
</section>
</section>
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2305.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,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

- 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.
36 changes: 20 additions & 16 deletions nixos/modules/services/monitoring/prometheus/exporters/pihole.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,72 @@ let
cfg = config.services.prometheus.exporters.pihole;
in
{
imports = [
(mkRemovedOptionModule [ "interval"] "This option has been removed.")
({ options.warnings = options.warnings; options.assertions = options.assertions; })
];

port = 9617;
extraOpts = {
apiToken = mkOption {
type = types.str;
default = "";
example = "580a770cb40511eb85290242ac130003580a770cb40511eb85290242ac130003";
description = lib.mdDoc ''
pi-hole API token which can be used instead of a password
'';
};
interval = mkOption {
drupol marked this conversation as resolved.
Show resolved Hide resolved
type = types.str;
default = "10s";
example = "30s";
description = lib.mdDoc ''
How often to scrape new data
Pi-Hole API token which can be used instead of a password
'';
};
password = mkOption {
type = types.str;
default = "";
example = "password";
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 {
type = types.str;
default = "pihole";
example = "127.0.0.1";
description = lib.mdDoc ''
Hostname or address where to find the pihole webinterface
Hostname or address where to find the Pi-Hole webinterface
'';
};
piholePort = mkOption {
type = types.port;
default = 80;
example = 443;
description = lib.mdDoc ''
The port pihole webinterface is reachable on
The port Pi-Hole webinterface is reachable on
'';
};
protocol = mkOption {
type = types.enum [ "http" "https" ];
default = "http";
example = "https";
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 = {
serviceConfig = {
ExecStart = ''
${pkgs.bash}/bin/bash -c "${pkgs.prometheus-pihole-exporter}/bin/pihole-exporter \
-interval ${cfg.interval} \
${pkgs.prometheus-pihole-exporter}/bin/pihole-exporter \
${optionalString (cfg.apiToken != "") "-pihole_api_token ${cfg.apiToken}"} \
-pihole_hostname ${cfg.piholeHostname} \
${optionalString (cfg.password != "") "-pihole_password ${cfg.password}"} \
-pihole_port ${toString cfg.piholePort} \
-pihole_protocol ${cfg.protocol} \
-port ${toString cfg.port}"
-port ${toString cfg.port} \
-timeout ${cfg.timeout}
'';
};
};
Expand Down