tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
heartbeat service: init
Tristan Helmich
8 years ago
97e84225
a20dbcb8
+74
-1
2 changed files
expand all
collapse all
unified
split
nixos
modules
module-list.nix
services
logging
heartbeat.nix
+2
-1
nixos/modules/module-list.nix
···
235
235
./services/hardware/udisks2.nix
236
236
./services/hardware/upower.nix
237
237
./services/hardware/thermald.nix
238
238
+
./services/logging/SystemdJournal2Gelf.nix
238
239
./services/logging/awstats.nix
239
240
./services/logging/fluentd.nix
240
241
./services/logging/graylog.nix
242
242
+
./services/logging/heartbeat.nix
241
243
./services/logging/journalbeat.nix
242
244
./services/logging/klogd.nix
243
245
./services/logging/logcheck.nix
244
246
./services/logging/logrotate.nix
245
247
./services/logging/logstash.nix
246
248
./services/logging/rsyslogd.nix
247
247
-
./services/logging/SystemdJournal2Gelf.nix
248
249
./services/logging/syslog-ng.nix
249
250
./services/logging/syslogd.nix
250
251
./services/mail/dovecot.nix
+72
nixos/modules/services/logging/heartbeat.nix
···
1
1
+
{ config, lib, pkgs, ... }:
2
2
+
3
3
+
with lib;
4
4
+
5
5
+
let
6
6
+
cfg = config.services.heartbeat;
7
7
+
8
8
+
heartbeatYml = pkgs.writeText "heartbeat.yml" ''
9
9
+
name: ${cfg.name}
10
10
+
tags: ${builtins.toJSON cfg.tags}
11
11
+
12
12
+
${cfg.extraConfig}
13
13
+
'';
14
14
+
15
15
+
in
16
16
+
{
17
17
+
options = {
18
18
+
19
19
+
services.heartbeat = {
20
20
+
21
21
+
enable = mkEnableOption "heartbeat";
22
22
+
23
23
+
name = mkOption {
24
24
+
type = types.str;
25
25
+
default = "heartbeat";
26
26
+
description = "Name of the beat";
27
27
+
};
28
28
+
29
29
+
tags = mkOption {
30
30
+
type = types.listOf types.str;
31
31
+
default = [];
32
32
+
description = "Tags to place on the shipped log messages";
33
33
+
};
34
34
+
35
35
+
stateDir = mkOption {
36
36
+
type = types.str;
37
37
+
default = "/var/lib/heartbeat";
38
38
+
description = "The state directory. heartbeat's own logs and other data are stored here.";
39
39
+
};
40
40
+
41
41
+
extraConfig = mkOption {
42
42
+
type = types.lines;
43
43
+
default = ''
44
44
+
heartbeat.monitors:
45
45
+
- type: http
46
46
+
urls: ["http://localhost:9200"]
47
47
+
schedule: '@every 10s'
48
48
+
'';
49
49
+
description = "Any other configuration options you want to add";
50
50
+
};
51
51
+
52
52
+
};
53
53
+
};
54
54
+
55
55
+
config = mkIf cfg.enable {
56
56
+
57
57
+
systemd.services.heartbeat = with pkgs; {
58
58
+
description = "heartbeat log shipper";
59
59
+
wantedBy = [ "multi-user.target" ];
60
60
+
preStart = ''
61
61
+
mkdir -p "${cfg.stateDir}"/{data,logs}
62
62
+
chown nobody:nogroup "${cfg.stateDir}"/{data,logs}
63
63
+
'';
64
64
+
serviceConfig = {
65
65
+
User = "nobody";
66
66
+
PermissionsStartOnly = true;
67
67
+
AmbientCapabilities = "cap_net_raw";
68
68
+
ExecStart = "${pkgs.heartbeat}/bin/heartbeat -c \"${heartbeatYml}\" -path.data \"${cfg.stateDir}/data\" -path.logs \"${cfg.stateDir}/logs\"";
69
69
+
};
70
70
+
};
71
71
+
};
72
72
+
}