1 { config, lib, pkgs, ... }:
4 cfg = config.services.sysstat;
8 enable = mkEnableOption (lib.mdDoc "sar system activity collection");
10 collect-frequency = mkOption {
13 description = lib.mdDoc ''
14 OnCalendar specification for sysstat-collect
18 collect-args = mkOption {
21 description = lib.mdDoc ''
22 Arguments to pass sa1 when collecting statistics
28 config = mkIf cfg.enable {
29 systemd.services.sysstat = {
30 description = "Resets System Activity Logs";
31 wantedBy = [ "multi-user.target" ];
35 RemainAfterExit = true;
37 ExecStart = "${pkgs.sysstat}/lib/sa/sa1 --boot";
42 systemd.services.sysstat-collect = {
43 description = "system activity accounting tool";
44 unitConfig.Documentation = "man:sa1(8)";
49 ExecStart = "${pkgs.sysstat}/lib/sa/sa1 ${cfg.collect-args}";
53 systemd.timers.sysstat-collect = {
54 description = "Run system activity accounting tool on a regular basis";
55 wantedBy = [ "timers.target" ];
56 timerConfig.OnCalendar = cfg.collect-frequency;
59 systemd.services.sysstat-summary = {
60 description = "Generate a daily summary of process accounting";
61 unitConfig.Documentation = "man:sa2(8)";
66 ExecStart = "${pkgs.sysstat}/lib/sa/sa2 -A";
70 systemd.timers.sysstat-summary = {
71 description = "Generate summary of yesterday's process accounting";
72 wantedBy = [ "timers.target" ];
73 timerConfig.OnCalendar = "00:07:00";