summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/prometheus-lvm-exporter.nix57
1 files changed, 57 insertions, 0 deletions
diff --git a/modules/prometheus-lvm-exporter.nix b/modules/prometheus-lvm-exporter.nix
new file mode 100644
index 00000000..f0951d46
--- /dev/null
+++ b/modules/prometheus-lvm-exporter.nix
@@ -0,0 +1,57 @@
1{ lib, config, pkgs, utils, ... }:
2
3with lib;
4
5let
6 cfg = config.services.prometheus.exporters.lvm;
7in {
8 options = {
9 services.prometheus.exporters.lvm = {
10 enable = mkEnableOption "Prometheus LVM exporter";
11
12 listenAddress = mkOption {
13 type = types.str;
14 default = "localhost";
15 };
16 port = mkOption {
17 type = types.port;
18 default = 9845;
19 };
20
21 openFirewall = mkOption {
22 type = types.bool;
23 default = false;
24 description = lib.mdDoc ''
25 Open port in firewall for incoming connections.
26 '';
27 };
28 firewallFilter = mkOption {
29 type = types.nullOr types.str;
30 default = null;
31 example = literalExpression ''
32 "-i eth0 -p tcp -m tcp --dport ${toString cfg.port}"
33 '';
34 description = lib.mdDoc ''
35 Specify a filter for iptables to use when
36 {option}`services.prometheus.exporters.lvm.openFirewall`
37 is true. It is used as `ip46tables -I nixos-fw firewallFilter -j nixos-fw-accept`.
38 '';
39 };
40 };
41 };
42
43 config = mkIf cfg.enable {
44 systemd.services."prometheus-lvm-exporter" = {
45 wantedBy = [ "multi-user.target" ];
46 after = [ "network.target" ];
47
48 serviceConfig = {
49 ExecStart = "${pkgs.prometheus-lvm-exporter}/bin/prometheus-lvm-exporter ${utils.escapeSystemdExecArgs [
50 "-web.listen-address" "${cfg.listenAddress}:${toString cfg.port}"
51 ]}";
52
53 Restart = "always";
54 };
55 };
56 };
57}