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