···
1
+
{ config, lib, pkgs, ... }:
4
+
cfg = config.services.sysstat;
12
+
Whether to enable sar system activity collection.
16
+
collect-frequency = mkOption {
17
+
default = "*:00/10";
19
+
OnCalendar specification for sysstat-collect
23
+
collect-args = mkOption {
26
+
Arguments to pass sa1 when collecting statistics
32
+
config = mkIf cfg.enable {
33
+
systemd.services.sysstat = {
34
+
description = "Resets System Activity Logs";
35
+
wantedBy = [ "multi-user.target" ];
36
+
preStart = "test -d /var/log/sa || mkdir -p /var/log/sa";
40
+
RemainAfterExit = true;
42
+
ExecStart = "${pkgs.sysstat}/lib/sa/sa1 --boot";
46
+
systemd.services.sysstat-collect = {
47
+
description = "system activity accounting tool";
48
+
unitConfig.Documentation = "man:sa1(8)";
53
+
ExecStart = "${pkgs.sysstat}/lib/sa/sa1 ${cfg.collect-args}";
57
+
systemd.timers.sysstat-collect = {
58
+
description = "Run system activity accounting tool on a regular basis";
59
+
wantedBy = [ "timers.target" ];
60
+
timerConfig.OnCalendar = cfg.collect-frequency;
63
+
systemd.services.sysstat-summary = {
64
+
description = "Generate a daily summary of process accounting";
65
+
unitConfig.Documentation = "man:sa2(8)";
70
+
ExecStart = "${pkgs.sysstat}/lib/sa/sa2 -A";
74
+
systemd.timers.sysstat-summary = {
75
+
description = "Generate summary of yesterday's process accounting";
76
+
wantedBy = [ "timers.target" ];
77
+
timerConfig.OnCalendar = "00:07:00";