nixos/prometheus/storagebox: Init module

This commit is contained in:
Dionysis Grigoropoulos
2025-09-26 13:27:03 +03:00
parent ee18acafa8
commit 377847e3c8
4 changed files with 65 additions and 0 deletions

View File

@@ -116,6 +116,8 @@
- [SuiteNumérique Meet](https://github.com/suitenumerique/meet) is an open source alternative to Google Meet and Zoom powered by LiveKit: HD video calls, screen sharing, and chat features. Built with Django and React. Available as [services.lasuite-meet](#opt-services.lasuite-meet.enable). - [SuiteNumérique Meet](https://github.com/suitenumerique/meet) is an open source alternative to Google Meet and Zoom powered by LiveKit: HD video calls, screen sharing, and chat features. Built with Django and React. Available as [services.lasuite-meet](#opt-services.lasuite-meet.enable).
- [Prometheus Storagebox Exporter](https://github.com/fleaz/prometheus-storagebox-exporter), a Prometheus exporter for Hetzner storage boxes.
- [lemurs](https://github.com/coastalwhite/lemurs), a customizable TUI display/login manager. Available at [services.displayManager.lemurs](#opt-services.displayManager.lemurs.enable). - [lemurs](https://github.com/coastalwhite/lemurs), a customizable TUI display/login manager. Available at [services.displayManager.lemurs](#opt-services.displayManager.lemurs.enable).
- [paisa](https://github.com/ananthakumaran/paisa), a personal finance tracker and dashboard. Available as [services.paisa](#opt-services.paisa.enable). - [paisa](https://github.com/ananthakumaran/paisa), a personal finance tracker and dashboard. Available as [services.paisa](#opt-services.paisa.enable).

View File

@@ -124,6 +124,7 @@ let
"snmp" "snmp"
"sql" "sql"
"statsd" "statsd"
"storagebox"
"surfboard" "surfboard"
"systemd" "systemd"
"tibber" "tibber"

View File

@@ -0,0 +1,47 @@
{
config,
lib,
pkgs,
options,
...
}:
let
cfg = config.services.prometheus.exporters.storagebox;
inherit (lib) mkPackageOption;
in
{
port = 9509;
extraOpts = {
package = mkPackageOption pkgs "prometheus-storagebox-exporter" { };
tokenFile = lib.mkOption {
type = lib.types.pathWith {
inStore = false;
absolute = true;
};
description = "File that contains the Hetzner API token to use.";
};
};
serviceOpts = {
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
script = ''
export HETZNER_TOKEN=$(< "''${CREDENTIALS_DIRECTORY}/token")
exec ${lib.getExe cfg.package}
'';
environment = {
LISTEN_ADDR = "${toString cfg.listenAddress}:${toString cfg.port}";
};
serviceConfig = {
DynamicUser = true;
Restart = "always";
RestartSec = "10s";
LoadCredential = [
"token:${cfg.tokenFile}"
];
};
};
}

View File

@@ -1615,6 +1615,21 @@ let
''; '';
}; };
storagebox = {
exporterConfig = {
enable = true;
tokenFile = "/tmp/faketoken";
};
exporterTest = ''
succeed(
'echo faketoken > /tmp/faketoken'
)
wait_for_unit("prometheus-storagebox-exporter.service")
wait_for_open_port(9509)
succeed("curl -sSf localhost:9509/metrics | grep 'process_open_fds'")
'';
};
snmp = { snmp = {
exporterConfig = { exporterConfig = {
enable = true; enable = true;