mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 13:41:26 +00:00
prometheus-unifi-exporter: init at 0.4.0
This commit is contained in:
parent
017fddb4be
commit
3728143cbc
|
@ -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
|
||||
|
|
104
nixos/modules/services/monitoring/prometheus/unifi-exporter.nix
Normal file
104
nixos/modules/services/monitoring/prometheus/unifi-exporter.nix
Normal file
|
@ -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}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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;
|
||||
};
|
||||
}
|
75
pkgs/servers/monitoring/prometheus/unifi-exporter/deps.nix
Normal file
75
pkgs/servers/monitoring/prometheus/unifi-exporter/deps.nix
Normal file
|
@ -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";
|
||||
};
|
||||
}
|
||||
]
|
|
@ -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 { };
|
||||
|
|
Loading…
Reference in a new issue