mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
heartbeat service: init
This commit is contained in:
parent
a20dbcb88b
commit
97e8422541
2 changed files with 74 additions and 1 deletions
|
@ -235,16 +235,17 @@
|
||||||
./services/hardware/udisks2.nix
|
./services/hardware/udisks2.nix
|
||||||
./services/hardware/upower.nix
|
./services/hardware/upower.nix
|
||||||
./services/hardware/thermald.nix
|
./services/hardware/thermald.nix
|
||||||
|
./services/logging/SystemdJournal2Gelf.nix
|
||||||
./services/logging/awstats.nix
|
./services/logging/awstats.nix
|
||||||
./services/logging/fluentd.nix
|
./services/logging/fluentd.nix
|
||||||
./services/logging/graylog.nix
|
./services/logging/graylog.nix
|
||||||
|
./services/logging/heartbeat.nix
|
||||||
./services/logging/journalbeat.nix
|
./services/logging/journalbeat.nix
|
||||||
./services/logging/klogd.nix
|
./services/logging/klogd.nix
|
||||||
./services/logging/logcheck.nix
|
./services/logging/logcheck.nix
|
||||||
./services/logging/logrotate.nix
|
./services/logging/logrotate.nix
|
||||||
./services/logging/logstash.nix
|
./services/logging/logstash.nix
|
||||||
./services/logging/rsyslogd.nix
|
./services/logging/rsyslogd.nix
|
||||||
./services/logging/SystemdJournal2Gelf.nix
|
|
||||||
./services/logging/syslog-ng.nix
|
./services/logging/syslog-ng.nix
|
||||||
./services/logging/syslogd.nix
|
./services/logging/syslogd.nix
|
||||||
./services/mail/dovecot.nix
|
./services/mail/dovecot.nix
|
||||||
|
|
72
nixos/modules/services/logging/heartbeat.nix
Normal file
72
nixos/modules/services/logging/heartbeat.nix
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.heartbeat;
|
||||||
|
|
||||||
|
heartbeatYml = pkgs.writeText "heartbeat.yml" ''
|
||||||
|
name: ${cfg.name}
|
||||||
|
tags: ${builtins.toJSON cfg.tags}
|
||||||
|
|
||||||
|
${cfg.extraConfig}
|
||||||
|
'';
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
|
||||||
|
services.heartbeat = {
|
||||||
|
|
||||||
|
enable = mkEnableOption "heartbeat";
|
||||||
|
|
||||||
|
name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "heartbeat";
|
||||||
|
description = "Name of the beat";
|
||||||
|
};
|
||||||
|
|
||||||
|
tags = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
|
description = "Tags to place on the shipped log messages";
|
||||||
|
};
|
||||||
|
|
||||||
|
stateDir = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "/var/lib/heartbeat";
|
||||||
|
description = "The state directory. heartbeat's own logs and other data are stored here.";
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = mkOption {
|
||||||
|
type = types.lines;
|
||||||
|
default = ''
|
||||||
|
heartbeat.monitors:
|
||||||
|
- type: http
|
||||||
|
urls: ["http://localhost:9200"]
|
||||||
|
schedule: '@every 10s'
|
||||||
|
'';
|
||||||
|
description = "Any other configuration options you want to add";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
systemd.services.heartbeat = with pkgs; {
|
||||||
|
description = "heartbeat log shipper";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
preStart = ''
|
||||||
|
mkdir -p "${cfg.stateDir}"/{data,logs}
|
||||||
|
chown nobody:nogroup "${cfg.stateDir}"/{data,logs}
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
User = "nobody";
|
||||||
|
PermissionsStartOnly = true;
|
||||||
|
AmbientCapabilities = "cap_net_raw";
|
||||||
|
ExecStart = "${pkgs.heartbeat}/bin/heartbeat -c \"${heartbeatYml}\" -path.data \"${cfg.stateDir}/data\" -path.logs \"${cfg.stateDir}/logs\"";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue