prometheus-tor-exporter: init at 0.3

Upstream: https://github.com/atx/prometheus-tor_exporter
This commit is contained in:
Pierre Bourdon 2018-10-13 10:07:05 +02:00
parent 5410e6b6b6
commit 86d644f8cc
4 changed files with 79 additions and 0 deletions

View File

@ -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; };
};

View File

@ -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}
'';
};
};
}

View File

@ -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;
};
}

View File

@ -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 { };