blob: a54e71a9d1eba493c095b1e2cae8e39b7d7c1b45 (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
{ config, lib, pkgs, ... }:
with builtins;
with lib;
let
cfg = config.lass.telegraf;
out = {
options.lass.telegraf = api;
config = mkIf cfg.enable imp;
};
api = {
enable = mkEnableOption "telegraf";
dataDir = mkOption {
type = types.str;
default = "/var/lib/telegraf";
};
user = mkOption {
type = types.str;
default = "telegraf";
};
outputs = mkOption {
type = types.str;
default = ''
[outputs.influxdb]
urls = ["http://localhost:8086"]
database = "all_data"
user_agent = "telegraf"
'';
};
inputs = mkOption {
type = with types; listOf str;
default = [
''
[cpu]
percpu = false
totalcpu = true
drop = ["cpu_time"]
''
];
};
config = mkOption {
type = types.str;
#TODO: find a good default
default = ''
[agent]
interval = "1s"
[outputs]
${cfg.outputs}
${concatStringsSep "\n" cfg.inputs}
'';
description = "configuration telegraf is started with";
};
};
configFile = pkgs.writeText "telegraf.conf" cfg.config;
imp = {
systemd.services.telegraf = {
description = "telegraf";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
restartIfChanged = true;
serviceConfig = {
Restart = "always";
ExecStart = "${pkgs.telegraf}/bin/telegraf -config ${configFile}";
};
};
};
in out
|