forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prometheus.exporters.qbittorrent: init
- Loading branch information
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
nixos/modules/services/monitoring/prometheus/exporters/qbittorrent.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# based on nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/deluge.nix | ||
|
||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
cfg = config.services.prometheus.exporters.qbittorrent; | ||
inherit (lib) mkOption mkPackageOption types concatStringsSep; | ||
in | ||
{ | ||
port = 9355; | ||
|
||
extraOpts = { | ||
package = mkPackageOption pkgs "prometheus-qbittorrent-exporter" { }; | ||
|
||
qbittorrentHost = mkOption { | ||
type = types.str; | ||
default = "localhost"; | ||
description = '' | ||
Hostname where qbittorrent is running. | ||
''; | ||
}; | ||
|
||
qbittorrentPort = mkOption { | ||
type = types.port; | ||
# TODO default? | ||
default = 1952; | ||
description = '' | ||
Port where qbittorrent is listening. | ||
''; | ||
}; | ||
|
||
qbittorrentUser = mkOption { | ||
type = types.str; | ||
default = "admin"; | ||
description = '' | ||
User to connect to qbittorrent. | ||
''; | ||
}; | ||
|
||
qbittorrentPassword = mkOption { | ||
type = types.nullOr types.str; | ||
default = null; | ||
description = '' | ||
Password to connect to qbittorrent. | ||
This stores the password unencrypted in the nix store and is thus considered unsafe. Prefer | ||
using the qbittorrentPasswordFile option. | ||
''; | ||
}; | ||
|
||
qbittorrentPasswordFile = mkOption { | ||
type = types.nullOr types.path; | ||
default = null; | ||
description = '' | ||
File containing the password to connect to qbittorrent. | ||
''; | ||
}; | ||
|
||
/* | ||
exportPerTorrentMetrics = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = '' | ||
Enable per-torrent metrics. | ||
This may significantly increase the number of time series depending on the number of | ||
torrents in your qbittorrent instance. | ||
''; | ||
}; | ||
*/ | ||
}; | ||
serviceOpts = { | ||
serviceConfig = { | ||
ExecStart = '' | ||
${cfg.package}/bin/qbittorrent-exporter | ||
''; | ||
Environment = [ | ||
"QBITTORRENT_HOST=${cfg.qbittorrentHost}" | ||
"QBITTORRENT_PORT=${toString cfg.qbittorrentPort}" | ||
# Whether to use SSL to connect or not. Will be forced to True when using port 443 | ||
"QBITTORRENT_SSL=False" | ||
# qbittorrent server path or base URL | ||
"QBITTORRENT_URL_BASE=" | ||
"QBITTORRENT_USER=${cfg.qbittorrentUser}" | ||
# https://github.com/esanchezm/prometheus-qbittorrent-exporter/issues/41 | ||
"EXPORTER_ADDRESS=${toString cfg.listenAddress}" | ||
"EXPORTER_PORT=${toString cfg.port}" | ||
# Log level. One of: DEBUG, INFO, WARNING, ERROR, CRITICAL | ||
"EXPORTER_LOG_LEVEL=INFO" | ||
# Prefix to add to all the metrics | ||
"METRICS_PREFIX=qbittorrent" | ||
# Whether to verify SSL certificate when connecting to the qbittorrent server. Any other value but True will disable the verification | ||
"VERIFY_WEBUI_CERTIFICATE=True" | ||
] ++ lib.optionals (cfg.qbittorrentPassword != null) [ | ||
"QBITTORRENT_PASS=${cfg.qbittorrentPassword}" | ||
]; | ||
EnvironmentFile = lib.optionalString (cfg.qbittorrentPasswordFile != null) "/etc/qbittorrent-exporter/password"; | ||
}; | ||
}; | ||
} |