about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2018-10-13 10:07:05 +0200
committerPierre Bourdon <delroth@gmail.com>2018-10-13 10:10:29 +0200
commit86d644f8cc85234e10165989ebc25e1da5135e99 (patch)
tree87ed6d898126ae92bda719bea5fe84c9a613f829 /nixos
parent5410e6b6b6b15721e0591c9b73b1d1bb1721d489 (diff)
downloadnixlib-86d644f8cc85234e10165989ebc25e1da5135e99.tar
nixlib-86d644f8cc85234e10165989ebc25e1da5135e99.tar.gz
nixlib-86d644f8cc85234e10165989ebc25e1da5135e99.tar.bz2
nixlib-86d644f8cc85234e10165989ebc25e1da5135e99.tar.lz
nixlib-86d644f8cc85234e10165989ebc25e1da5135e99.tar.xz
nixlib-86d644f8cc85234e10165989ebc25e1da5135e99.tar.zst
nixlib-86d644f8cc85234e10165989ebc25e1da5135e99.zip
prometheus-tor-exporter: init at 0.3
Upstream: https://github.com/atx/prometheus-tor_exporter
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters.nix1
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/tor.nix40
2 files changed, 41 insertions, 0 deletions
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}
+      '';
+    };
+  };
+}