diff options
author | Pascal Bach <pascal.bach@nextrem.ch> | 2017-03-07 22:59:57 +0100 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2017-03-15 17:22:36 +0100 |
commit | a8cca7037e445915b5c58a582eae270e65065678 (patch) | |
tree | 17ef0d6d052b85c36f721f58e040fbfd077f174e /nixos/modules/services/monitoring | |
parent | 9adcebb1a97ac75b8a2445459f9e3826a7b71a39 (diff) | |
download | nixlib-a8cca7037e445915b5c58a582eae270e65065678.tar nixlib-a8cca7037e445915b5c58a582eae270e65065678.tar.gz nixlib-a8cca7037e445915b5c58a582eae270e65065678.tar.bz2 nixlib-a8cca7037e445915b5c58a582eae270e65065678.tar.lz nixlib-a8cca7037e445915b5c58a582eae270e65065678.tar.xz nixlib-a8cca7037e445915b5c58a582eae270e65065678.tar.zst nixlib-a8cca7037e445915b5c58a582eae270e65065678.zip |
prometheus-fritzbox-exporter: init at 1.0
Diffstat (limited to 'nixos/modules/services/monitoring')
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/fritzbox-exporter.nix | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/fritzbox-exporter.nix b/nixos/modules/services/monitoring/prometheus/fritzbox-exporter.nix new file mode 100644 index 000000000000..6da39b6519cb --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/fritzbox-exporter.nix @@ -0,0 +1,76 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.prometheus.fritzboxExporter; +in { + options = { + services.prometheus.fritzboxExporter = { + enable = mkEnableOption "prometheus fritzbox exporter"; + + port = mkOption { + type = types.int; + default = 9133; + description = '' + Port to listen on. + ''; + }; + + gatewayAddress = mkOption { + type = types.str; + default = "fritz.box"; + description = '' + The hostname or IP of the FRITZ!Box. + ''; + }; + + gatewayPort = mkOption { + type = types.int; + default = 49000; + description = '' + The port of the FRITZ!Box UPnP service. + ''; + }; + + extraFlags = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra commandline options when launching the fritzbox exporter. + ''; + }; + + openFirewall = mkOption { + type = types.bool; + default = false; + description = '' + Open port in firewall for incoming connections. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + networking.firewall.allowedTCPPorts = optional cfg.openFirewall cfg.port; + + systemd.services.prometheus-fritzbox-exporter = { + description = "Prometheus exporter for FRITZ!Box via UPnP"; + unitConfig.Documentation = "https://github.com/ndecker/fritzbox_exporter"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "nobody"; + Restart = "always"; + PrivateTmp = true; + WorkingDirectory = /tmp; + ExecStart = '' + ${pkgs.prometheus-fritzbox-exporter}/bin/fritzbox_exporter \ + -listen-address :${toString cfg.port} \ + -gateway-address ${cfg.gatewayAddress} \ + -gateway-port ${toString cfg.gatewayPort} \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + }; + }; + }; +} |