diff --git a/machines/fuuko/services/prometheus.nix b/machines/fuuko/services/prometheus.nix index e664add..91acbcb 100644 --- a/machines/fuuko/services/prometheus.nix +++ b/machines/fuuko/services/prometheus.nix @@ -66,6 +66,10 @@ in "vueko.vpn.sbruder.de:9100" ]; } + { + job_name = "fritzbox"; + static_configs = mkStaticTarget "127.0.0.1:9133"; + } ]; rules = @@ -113,8 +117,19 @@ in }; }) ]; + + exporters = { + fritzbox = { + enable = true; + gatewayAddress = "192.168.100.1"; + listenAddress = "127.0.0.1"; + }; + }; }; + # get rid of “could not call action: authorization required” every scrape + systemd.services.prometheus-fritzbox-exporter.serviceConfig.StandardOutput = "null"; + krops.secrets.prometheus-htpasswd = { group = "nginx"; }; diff --git a/pkgs/default.nix b/pkgs/default.nix index b2704f0..38192db 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -18,6 +18,10 @@ in aria2_exporter = import srcs.aria2_exporter { pkgs = self; }; + # adapted nixpkgs upstream but changed to buildGoModule and updated to + # version that works in my setup + prometheus-fritzbox-exporter = super.callPackage ./prometheus-fritzbox-exporter { }; + # FIXME: 21.05: Move to home-manager module package attribute mpv-unwrapped = super.mpv-unwrapped.overrideAttrs (o: o // { patches = [ diff --git a/pkgs/prometheus-fritzbox-exporter/default.nix b/pkgs/prometheus-fritzbox-exporter/default.nix new file mode 100644 index 0000000..489d048 --- /dev/null +++ b/pkgs/prometheus-fritzbox-exporter/default.nix @@ -0,0 +1,28 @@ +{ stdenv, buildGoModule, fetchFromGitHub, nixosTests }: + +buildGoModule rec { + pname = "fritzbox-exporter"; + version = "unstable-2021-03-03"; + rev = "6d66f6b8e47878c61feb710e36306fe714350658"; + + src = fetchFromGitHub { + inherit rev; + owner = "mxschmitt"; + repo = "fritzbox_exporter"; + sha256 = "0n9fwslcwgfghscrwbz7p3zamb474zk425ijkkh6cixpnc7p3vi6"; + }; + + subPackages = [ "cmd/exporter" ]; + + vendorSha256 = "0k6bd052pjfg5c1ba1yhni8msv3wl512vfzy2hrk49jibh8h052n"; + + passthru.tests = { inherit (nixosTests.prometheus-exporters) fritzbox; }; + + meta = with stdenv.lib; { + description = "Prometheus Exporter for FRITZ!Box (TR64 and UPnP)"; + homepage = "https://github.com/mxschmitt/fritzbox_exporter"; + license = licenses.asl20; + maintainers = with maintainers; [ bachp flokli ]; + platforms = platforms.unix; + }; +}