summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorAlexey Shmalko <rasen.dubi@gmail.com>2018-10-13 17:59:23 +0300
committerGitHub <noreply@github.com>2018-10-13 17:59:23 +0300
commitdf2696c4305a11ea6c986e50ac51dd85ba55723f (patch)
tree117d14d1b2868099cb25bb554d8fb2ecc0170ced /nixos/modules
parent49284e4a00a1b8a93d1ae93896f3856c98f5f266 (diff)
parent86d644f8cc85234e10165989ebc25e1da5135e99 (diff)
downloadnixpkgs-df2696c4305a11ea6c986e50ac51dd85ba55723f.tar
nixpkgs-df2696c4305a11ea6c986e50ac51dd85ba55723f.tar.gz
nixpkgs-df2696c4305a11ea6c986e50ac51dd85ba55723f.tar.bz2
nixpkgs-df2696c4305a11ea6c986e50ac51dd85ba55723f.tar.lz
nixpkgs-df2696c4305a11ea6c986e50ac51dd85ba55723f.tar.xz
nixpkgs-df2696c4305a11ea6c986e50ac51dd85ba55723f.tar.zst
nixpkgs-df2696c4305a11ea6c986e50ac51dd85ba55723f.zip
Merge pull request #48307 from delroth/prom-tor
 prometheus-tor-exporter: init at 0.3
Diffstat (limited to 'nixos/modules')
-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 ae8caac436d..950af848c0f 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 00000000000..0e2a13c44ab
--- /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}
+      '';
+    };
+  };
+}