diff options
author | WilliButz <WilliButz@users.noreply.github.com> | 2023-09-25 12:09:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-25 12:09:36 +0200 |
commit | 2d30a37d9f4bc44a28be007296a120be398e2ede (patch) | |
tree | 30e5c902648614722bb5d0b398ef682e1a5e8610 /nixos/modules/services/monitoring/prometheus/exporters | |
parent | f4822bb295ea194a1278af287771c615636cbcbf (diff) | |
parent | 5e75b3630247c5be083a8af40ebe3c5528f531f4 (diff) | |
download | nixpkgs-2d30a37d9f4bc44a28be007296a120be398e2ede.tar nixpkgs-2d30a37d9f4bc44a28be007296a120be398e2ede.tar.gz nixpkgs-2d30a37d9f4bc44a28be007296a120be398e2ede.tar.bz2 nixpkgs-2d30a37d9f4bc44a28be007296a120be398e2ede.tar.lz nixpkgs-2d30a37d9f4bc44a28be007296a120be398e2ede.tar.xz nixpkgs-2d30a37d9f4bc44a28be007296a120be398e2ede.tar.zst nixpkgs-2d30a37d9f4bc44a28be007296a120be398e2ede.zip |
Merge pull request #248925 from FugiMuffi/prometheus-sabnzbd-exporter
prometheus-sabnzbd-exporter: init at 0.1.70
Diffstat (limited to 'nixos/modules/services/monitoring/prometheus/exporters')
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters/sabnzbd.nix | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/sabnzbd.nix b/nixos/modules/services/monitoring/prometheus/exporters/sabnzbd.nix new file mode 100644 index 00000000000..41127749401 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters/sabnzbd.nix @@ -0,0 +1,47 @@ +{ config, lib, pkgs, options }: + +let + inherit (lib) mkOption types; + cfg = config.services.prometheus.exporters.sabnzbd; +in +{ + port = 9387; + + extraOpts = { + servers = mkOption { + description = "List of sabnzbd servers to connect to."; + type = types.listOf (types.submodule { + options = { + baseUrl = mkOption { + type = types.str; + description = "Base URL of the sabnzbd server."; + example = "http://localhost:8080/sabnzbd"; + }; + apiKeyFile = mkOption { + type = types.str; + description = "File containing the API key."; + example = "/run/secrets/sabnzbd_apikey"; + }; + }; + }); + }; + }; + + serviceOpts = + let + servers = lib.zipAttrs cfg.servers; + apiKeys = lib.concatStringsSep "," (builtins.map (file: "$(cat ${file})") servers.apiKeyFile); + in + { + environment = { + METRICS_PORT = toString cfg.port; + METRICS_ADDR = cfg.listenAddress; + SABNZBD_BASEURLS = lib.concatStringsSep "," servers.baseUrl; + }; + + script = '' + export SABNZBD_APIKEYS="${apiKeys}" + exec ${lib.getExe pkgs.prometheus-sabnzbd-exporter} + ''; + }; +} |