summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-11-11 16:15:19 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-11-11 16:15:19 +0100
commit8fda0125d8641018db73b2ccafe8b8302937660f (patch)
tree3f5a98d2baf692cc7098dce1abedb50359c3b68e /modules
parent7e97353075b4acee96488d022e456f80f4f903ed (diff)
downloadnixos-8fda0125d8641018db73b2ccafe8b8302937660f.tar
nixos-8fda0125d8641018db73b2ccafe8b8302937660f.tar.gz
nixos-8fda0125d8641018db73b2ccafe8b8302937660f.tar.bz2
nixos-8fda0125d8641018db73b2ccafe8b8302937660f.tar.xz
nixos-8fda0125d8641018db73b2ccafe8b8302937660f.zip
...
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}