added prometheus-borgmatic-exporter module

Changed files
+55
nixos
modules
services
monitoring
prometheus
tests
+1
nixos/modules/services/monitoring/prometheus/exporters.nix
···
"bird"
"bitcoin"
"blackbox"
+
"borgmatic"
"buildkite-agent"
"collectd"
"deluge"
+34
nixos/modules/services/monitoring/prometheus/exporters/borgmatic.nix
···
+
{
+
config,
+
lib,
+
pkgs,
+
...
+
}:
+
+
let
+
cfg = config.services.prometheus.exporters.borgmatic;
+
in
+
{
+
port = 9996;
+
extraOpts.configFile = lib.mkOption {
+
type = lib.types.path;
+
default = "/etc/borgmatic/config.yaml";
+
description = ''
+
The path to the borgmatic config file
+
'';
+
};
+
+
serviceOpts = {
+
serviceConfig = {
+
DynamicUser = false;
+
ProtectSystem = false;
+
ProtectHome = lib.mkForce false;
+
ExecStart = ''
+
${pkgs.prometheus-borgmatic-exporter}/bin/borgmatic-exporter run \
+
--port ${toString cfg.port} \
+
--config ${toString cfg.configFile} \
+
${lib.concatMapStringsSep " " (f: lib.escapeShellArg f) cfg.extraFlags}
+
'';
+
};
+
};
+
}
+20
nixos/tests/prometheus-exporters.nix
···
'';
};
+
borgmatic = {
+
exporterConfig = {
+
enable = true;
+
user = "root";
+
};
+
metricProvider = {
+
services.borgmatic.enable = true;
+
services.borgmatic.settings.source_directories = [ "/home" ];
+
services.borgmatic.settings.repositories = [ { label = "local"; path = "/var/backup"; } ];
+
services.borgmatic.settings.keep_daily = 10;
+
};
+
exporterTest = ''
+
succeed("borgmatic rcreate -e none")
+
succeed("borgmatic")
+
wait_for_unit("prometheus-borgmatic-exporter.service")
+
wait_for_open_port(9996)
+
succeed("curl -sSf localhost:9996/metrics | grep 'borg_total_backups{repository=\"/var/backup\"} 1'")
+
'';
+
};
+
collectd = {
exporterConfig = {
enable = true;