2024-11-07 22:58:22 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.fritzbox;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.fritzbox = with lib; {
|
|
|
|
enable = mkEnableOption "Fritzbox-Monitoring";
|
|
|
|
|
|
|
|
username = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "prometheus";
|
|
|
|
example = "admin";
|
|
|
|
description = "Admin username";
|
|
|
|
};
|
|
|
|
|
|
|
|
passwordFile = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "/var/lib/fritz/password.txt";
|
|
|
|
description = "password stored in a file";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services = {
|
|
|
|
prometheus.exporters.fritz = {
|
2025-02-25 23:53:44 +01:00
|
|
|
inherit (cfg) enable;
|
2024-11-07 22:58:22 +01:00
|
|
|
settings.devices = [
|
|
|
|
{
|
|
|
|
inherit (cfg) username;
|
|
|
|
password_file = cfg.passwordFile;
|
|
|
|
host_info = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
prometheus.scrapeConfigs = [
|
|
|
|
{
|
|
|
|
job_name = "fritzbox";
|
|
|
|
static_configs = [
|
|
|
|
{
|
2025-02-25 23:53:44 +01:00
|
|
|
targets = [ "localhost:${toString config.services.prometheus.exporters.fritzbox.port}" ];
|
2024-11-07 22:58:22 +01:00
|
|
|
labels = {
|
|
|
|
instance = config.networking.hostName;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
grafana.provision = {
|
|
|
|
dashboards.settings.providers = [
|
|
|
|
{
|
|
|
|
name = "Fritzbox";
|
|
|
|
options.path = pkgs.grafana-dashboards.fritzbox;
|
|
|
|
disableDeletion = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|