blob: 28821267b4f3e718b4db5c284d54fc63492846f8 (
plain) (
blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
|
{ config, pkgs, lib, ... }:
with pkgs;
with lib;
let
cfg = config.services.riemann-tools;
riemannHost = "${cfg.riemannHost}";
healthLauncher = writeScriptBin "riemann-health" ''
#!/bin/sh
exec ${pkgs.riemann-tools}/bin/riemann-health ${builtins.concatStringsSep " " cfg.extraArgs} --host ${riemannHost}
'';
in {
options = {
services.riemann-tools = {
enableHealth = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc ''
Enable the riemann-health daemon.
'';
};
riemannHost = mkOption {
type = types.str;
default = "127.0.0.1";
description = lib.mdDoc ''
Address of the host riemann node. Defaults to localhost.
'';
};
extraArgs = mkOption {
type = types.listOf types.str;
default = [];
description = lib.mdDoc ''
A list of commandline-switches forwarded to a riemann-tool.
See for example `riemann-health --help` for available options.
'';
example = ["-p 5555" "--timeout=30" "--attribute=myattribute=42"];
};
};
};
config = mkIf cfg.enableHealth {
users.groups.riemanntools.gid = config.ids.gids.riemanntools;
users.users.riemanntools = {
description = "riemann-tools daemon user";
uid = config.ids.uids.riemanntools;
group = "riemanntools";
};
systemd.services.riemann-health = {
wantedBy = [ "multi-user.target" ];
path = [ procps ];
serviceConfig = {
User = "riemanntools";
ExecStart = "${healthLauncher}/bin/riemann-health";
};
};
};
}
|