diff --git a/nixos/modules/services/monitoring/munin.nix b/nixos/modules/services/monitoring/munin.nix index 364f18e7543..b8c26a5c89b 100644 --- a/nixos/modules/services/monitoring/munin.nix +++ b/nixos/modules/services/monitoring/munin.nix @@ -193,14 +193,26 @@ in }) (mkIf cronCfg.enable { - services.cron.systemCronJobs = [ - "*/5 * * * * munin ${pkgs.munin}/bin/munin-cron --config ${muninConf}" - ]; + systemd.timers.munin-cron = { + description = "batch Munin master programs"; + wantedBy = [ "timers.target" ]; + timerConfig.OnCalendar = "*:0/5"; + }; + + systemd.services.munin-cron = { + description = "batch Munin master programs"; + unitConfig.Documentation = "man:munin-cron(8)"; + + serviceConfig = { + Type = "oneshot"; + User = "munin"; + ExecStart = "${pkgs.munin}/bin/munin-cron --config ${muninConf}"; + }; + }; system.activationScripts.munin-cron = stringAfter [ "users" "groups" ] '' mkdir -p /var/{run,log,www,lib}/munin chown -R munin:munin /var/{run,log,www,lib}/munin ''; - })]; } diff --git a/nixos/tests/munin.nix b/nixos/tests/munin.nix index 50746d17b45..40fafc62514 100644 --- a/nixos/tests/munin.nix +++ b/nixos/tests/munin.nix @@ -29,6 +29,7 @@ import ./make-test.nix ({ pkgs, ...} : { startAll; $one->waitForUnit("munin-node.service"); + $one->succeed('systemctl start munin-cron'); $one->waitForFile("/var/lib/munin/one/one-uptime-uptime-g.rrd"); $one->waitForFile("/var/www/munin/one/index.html"); '';