diff options
author | Pascal Bach <pascal.bach@nextrem.ch> | 2017-03-07 23:47:05 +0100 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2017-03-17 15:41:22 +0100 |
commit | 3728143cbcead48f387dd7297f76138a82ed04de (patch) | |
tree | 5a81b8caf398eeab0c0fcfd629cd0d3e3448432b | |
parent | 017fddb4be7d5c074a0b3e2dfb26b88d5e90ceaf (diff) | |
download | nixpkgs-3728143cbcead48f387dd7297f76138a82ed04de.tar nixpkgs-3728143cbcead48f387dd7297f76138a82ed04de.tar.gz nixpkgs-3728143cbcead48f387dd7297f76138a82ed04de.tar.bz2 nixpkgs-3728143cbcead48f387dd7297f76138a82ed04de.tar.lz nixpkgs-3728143cbcead48f387dd7297f76138a82ed04de.tar.xz nixpkgs-3728143cbcead48f387dd7297f76138a82ed04de.tar.zst nixpkgs-3728143cbcead48f387dd7297f76138a82ed04de.zip |
prometheus-unifi-exporter: init at 0.4.0
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/unifi-exporter.nix | 104 | ||||
-rw-r--r-- | pkgs/servers/monitoring/prometheus/unifi-exporter/default.nix | 26 | ||||
-rw-r--r-- | pkgs/servers/monitoring/prometheus/unifi-exporter/deps.nix | 75 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 1 |
5 files changed, 207 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 627807edb90..d6bc34be686 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -334,6 +334,7 @@ ./services/monitoring/prometheus/nginx-exporter.nix ./services/monitoring/prometheus/node-exporter.nix ./services/monitoring/prometheus/snmp-exporter.nix + ./services/monitoring/prometheus/unifi-exporter.nix ./services/monitoring/prometheus/varnish-exporter.nix ./services/monitoring/riemann.nix ./services/monitoring/riemann-dash.nix diff --git a/nixos/modules/services/monitoring/prometheus/unifi-exporter.nix b/nixos/modules/services/monitoring/prometheus/unifi-exporter.nix new file mode 100644 index 00000000000..e3059e48509 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/unifi-exporter.nix @@ -0,0 +1,104 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.prometheus.unifiExporter; +in { + options = { + services.prometheus.unifiExporter = { + enable = mkEnableOption "prometheus unifi exporter"; + + port = mkOption { + type = types.int; + default = 9130; + description = '' + Port to listen on. + ''; + }; + + unifiAddress = mkOption { + type = types.str; + example = "https://10.0.0.1:8443"; + description = '' + URL of the UniFi Controller API. + ''; + }; + + unifiInsecure = mkOption { + type = types.bool; + default = false; + description = '' + If enabled skip the verification of the TLS certificate of the UniFi Controller API. + Use with caution. + ''; + }; + + unifiUsername = mkOption { + type = types.str; + example = "ReadOnlyUser"; + description = '' + username for authentication against UniFi Controller API. + ''; + }; + + unifiPassword = mkOption { + type = types.str; + description = '' + Password for authentication against UniFi Controller API. + ''; + }; + + unifiTimeout = mkOption { + type = types.str; + default = "5s"; + example = "2m"; + description = '' + Timeout including unit for UniFi Controller API requests. + ''; + }; + + extraFlags = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra commandline options when launching the unifi 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-unifi-exporter = { + description = "Prometheus exporter for UniFi Controller metrics"; + unitConfig.Documentation = "https://github.com/mdlayher/unifi_exporter"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "nobody"; + Restart = "always"; + PrivateTmp = true; + WorkingDirectory = /tmp; + ExecStart = '' + ${pkgs.prometheus-unifi-exporter}/bin/unifi_exporter \ + -telemetry.addr :${toString cfg.port} \ + -unifi.addr ${cfg.unifiAddress} \ + -unifi.username ${cfg.unifiUsername} \ + -unifi.password ${cfg.unifiPassword} \ + -unifi.timeout ${cfg.unifiTimeout} \ + ${optionalString cfg.unifiInsecure "-unifi.insecure" } \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + }; + }; + }; +} diff --git a/pkgs/servers/monitoring/prometheus/unifi-exporter/default.nix b/pkgs/servers/monitoring/prometheus/unifi-exporter/default.nix new file mode 100644 index 00000000000..f866df49b54 --- /dev/null +++ b/pkgs/servers/monitoring/prometheus/unifi-exporter/default.nix @@ -0,0 +1,26 @@ +{ stdenv, lib, buildGoPackage, fetchFromGitHub }: + +buildGoPackage rec { + name = "unifi-exporter-${version}"; + version = "0.4.0"; + rev = version; + + goPackagePath = "github.com/mdlayher/unifi_exporter"; + + src= fetchFromGitHub { + inherit rev; + owner = "mdlayher"; + repo = "unifi_exporter"; + sha256 = "0mbav3dkrwrgzzl80q590467nbq5j61v5v7mpsbhcn2p7ak0swx4"; + }; + + goDeps = ./deps.nix; + + meta = with stdenv.lib; { + description = "Prometheus exporter that exposes metrics from a Ubiquiti UniFi Controller and UniFi devices"; + homepage = https://github.com/mdlayher/unifi_exporter; + license = licenses.mit; + maintainers = with maintainers; [ bachp ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/servers/monitoring/prometheus/unifi-exporter/deps.nix b/pkgs/servers/monitoring/prometheus/unifi-exporter/deps.nix new file mode 100644 index 00000000000..1de25a21d8c --- /dev/null +++ b/pkgs/servers/monitoring/prometheus/unifi-exporter/deps.nix @@ -0,0 +1,75 @@ +# This file was generated by go2nix. +[ + { + goPackagePath = "github.com/beorn7/perks"; + fetch = { + type = "git"; + url = "https://github.com/beorn7/perks"; + rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9"; + sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y"; + }; + } + { + goPackagePath = "github.com/golang/protobuf"; + fetch = { + type = "git"; + url = "https://github.com/golang/protobuf"; + rev = "c9c7427a2a70d2eb3bafa0ab2dc163e45f143317"; + sha256 = "1xy0bj66qks2xlzxzlfma16w7m8g6rrwawmlhlv68bcw2k5hvvib"; + }; + } + { + goPackagePath = "github.com/matttproud/golang_protobuf_extensions"; + fetch = { + type = "git"; + url = "https://github.com/matttproud/golang_protobuf_extensions"; + rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c"; + sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya"; + }; + } + { + goPackagePath = "github.com/mdlayher/unifi"; + fetch = { + type = "git"; + url = "https://github.com/mdlayher/unifi"; + rev = "418aad77bdb31a9b97d13f79162b0bac1a38bb25"; + sha256 = "16hv2mk2vl4lcj1qf2wp9psvffz26b5zsajs2yl21rbx0pcwkcp7"; + }; + } + { + goPackagePath = "github.com/prometheus/client_golang"; + fetch = { + type = "git"; + url = "https://github.com/prometheus/client_golang"; + rev = "a5060f1eaab721946b185b2de468ff83ea5b89cb"; + sha256 = "1v9qva9c0wrjkl71b0rvvi1qj7l42gvcsj349r4lg8pwni8i6did"; + }; + } + { + goPackagePath = "github.com/prometheus/client_model"; + fetch = { + type = "git"; + url = "https://github.com/prometheus/client_model"; + rev = "6f3806018612930941127f2a7c6c453ba2c527d2"; + sha256 = "1413ibprinxhni51p0755dp57r9wvbw7xgj9nmdaxmhzlqhc86j4"; + }; + } + { + goPackagePath = "github.com/prometheus/common"; + fetch = { + type = "git"; + url = "https://github.com/prometheus/common"; + rev = "49fee292b27bfff7f354ee0f64e1bc4850462edf"; + sha256 = "01vcjzkxs34yyy402rsbxw3md7ia85ls9yzsxhgddcisa3mq23cj"; + }; + } + { + goPackagePath = "github.com/prometheus/procfs"; + fetch = { + type = "git"; + url = "https://github.com/prometheus/procfs"; + rev = "a1dba9ce8baed984a2495b658c82687f8157b98f"; + sha256 = "1k2460bjzsm238sqx7wi42bym5bk7ybdr4qadk9szdbv65hh8vf6"; + }; + } +] diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bb00f2b07fd..aedf54c708a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10825,6 +10825,7 @@ with pkgs; prometheus-pushgateway = callPackage ../servers/monitoring/prometheus/pushgateway.nix { }; prometheus-snmp-exporter = callPackage ../servers/monitoring/prometheus/snmp-exporter.nix { }; prometheus-statsd-bridge = callPackage ../servers/monitoring/prometheus/statsd-bridge.nix { }; + prometheus-unifi-exporter = callPackage ../servers/monitoring/prometheus/unifi-exporter { }; prometheus-varnish-exporter = callPackage ../servers/monitoring/prometheus/varnish-exporter.nix { }; psqlodbc = callPackage ../servers/sql/postgresql/psqlodbc { }; |