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