From 5410e6b6b6b15721e0591c9b73b1d1bb1721d489 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sat, 13 Oct 2018 10:10:02 +0200 Subject: [PATCH 1/2] maintainers: add delroth --- maintainers/maintainer-list.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index e7756f0bff11..3a50eb2819b8 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -986,6 +986,11 @@ github = "deepfire"; name = "Kosyrev Serge"; }; + delroth = { + email = "delroth@gmail.com"; + github = "delroth"; + name = "Pierre Bourdon"; + }; deltaevo = { email = "deltaduartedavid@gmail.com"; github = "DeltaEvo"; From 86d644f8cc85234e10165989ebc25e1da5135e99 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sat, 13 Oct 2018 10:07:05 +0200 Subject: [PATCH 2/2] prometheus-tor-exporter: init at 0.3 Upstream: https://github.com/atx/prometheus-tor_exporter --- .../monitoring/prometheus/exporters.nix | 1 + .../monitoring/prometheus/exporters/tor.nix | 40 +++++++++++++++++++ .../monitoring/prometheus/tor-exporter.nix | 37 +++++++++++++++++ pkgs/top-level/all-packages.nix | 1 + 4 files changed, 79 insertions(+) create mode 100644 nixos/modules/services/monitoring/prometheus/exporters/tor.nix create mode 100644 pkgs/servers/monitoring/prometheus/tor-exporter.nix diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index ae8caac436da..950af848c0f6 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -30,6 +30,7 @@ let postfix = import ./exporters/postfix.nix { inherit config lib pkgs; }; snmp = import ./exporters/snmp.nix { inherit config lib pkgs; }; surfboard = import ./exporters/surfboard.nix { inherit config lib pkgs; }; + tor = import ./exporters/tor.nix { inherit config lib pkgs; }; unifi = import ./exporters/unifi.nix { inherit config lib pkgs; }; varnish = import ./exporters/varnish.nix { inherit config lib pkgs; }; }; diff --git a/nixos/modules/services/monitoring/prometheus/exporters/tor.nix b/nixos/modules/services/monitoring/prometheus/exporters/tor.nix new file mode 100644 index 000000000000..0e2a13c44ab7 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters/tor.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs }: + +with lib; + +let + cfg = config.services.prometheus.exporters.tor; +in +{ + port = 9130; + extraOpts = { + torControlAddress = mkOption { + type = types.str; + default = "127.0.0.1"; + description = '' + Tor control IP address or hostname. + ''; + }; + + torControlPort = mkOption { + type = types.int; + default = 9051; + description = '' + Tor control port. + ''; + }; + }; + serviceOpts = { + serviceConfig = { + DynamicUser = true; + ExecStart = '' + ${pkgs.prometheus-tor-exporter}/bin/prometheus-tor-exporter \ + -b ${cfg.listenAddress} \ + -p ${toString cfg.port} \ + -a ${cfg.torControlAddress} \ + -c ${toString cfg.torControlPort} \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + }; + }; +} diff --git a/pkgs/servers/monitoring/prometheus/tor-exporter.nix b/pkgs/servers/monitoring/prometheus/tor-exporter.nix new file mode 100644 index 000000000000..88f469ebe179 --- /dev/null +++ b/pkgs/servers/monitoring/prometheus/tor-exporter.nix @@ -0,0 +1,37 @@ +{ lib, fetchFromGitHub, python3Packages }: + +python3Packages.buildPythonApplication rec { + name = "tor-exporter-${version}"; + version = "0.3"; + + # Just a single .py file to use as the application's main entry point. + format = "other"; + + src = fetchFromGitHub { + rev = "v${version}"; + owner = "atx"; + repo = "prometheus-tor_exporter"; + sha256 = "0d7pk8s8ya2pm8b4ijbfdniqcbd3vqy15dlhnmaf4wgb51pmm5yv"; + }; + + propagatedBuildInputs = with python3Packages; [ prometheus_client stem retrying ]; + + installPhase = '' + mkdir -p $out/share/ + cp prometheus-tor-exporter.py $out/share/ + ''; + + fixupPhase = '' + makeWrapper "${python3Packages.python.interpreter}" "$out/bin/prometheus-tor-exporter" \ + --set PYTHONPATH "$PYTHONPATH" \ + --add-flags "$out/share/prometheus-tor-exporter.py" + ''; + + meta = with lib; { + description = "Prometheus exporter that exposes metrics from a Tor daemon"; + homepage = https://github.com/atx/prometheus-tor_exporter; + license = licenses.mit; + maintainers = with maintainers; [ delroth ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8f4bc519285f..e837d5049f84 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13530,6 +13530,7 @@ with pkgs; prometheus-snmp-exporter = callPackage ../servers/monitoring/prometheus/snmp-exporter.nix { buildGoPackage = buildGo110Package; }; + prometheus-tor-exporter = callPackage ../servers/monitoring/prometheus/tor-exporter.nix { }; prometheus-statsd-exporter = callPackage ../servers/monitoring/prometheus/statsd-bridge.nix { }; prometheus-surfboard-exporter = callPackage ../servers/monitoring/prometheus/surfboard-exporter.nix { }; prometheus-unifi-exporter = callPackage ../servers/monitoring/prometheus/unifi-exporter { };