From 1bee8e81f99a64ad21774d8bee9b8b1957b7e485 Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Tue, 11 Jun 2024 15:46:58 -0400 Subject: Fix dynamic DNS retries and e-mail alert throttling --- hostnix/elmo/dyndns.nix | 12 ++++++++---- hostnix/elmo/system.nix | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hostnix/elmo/dyndns.nix b/hostnix/elmo/dyndns.nix index 5abe98c..33ce19d 100644 --- a/hostnix/elmo/dyndns.nix +++ b/hostnix/elmo/dyndns.nix @@ -27,15 +27,19 @@ after = [ "network-online.target" ]; unitConfig = { AssertPathExists = "/var/secrets/dyndns"; - # Defer errors for ~45min, throttle e-mails to ~hourly. - StartLimitIntervalSec = "1hr"; - StartLimitBurst = "45"; + # Retry ~3min before giving up. + StartLimitIntervalSec = "5min"; + StartLimitBurst = "7"; OnFailure = "status-email@%n.service"; }; serviceConfig = { Type = "oneshot"; Restart = "on-failure"; - RestartSec = "1min"; + # Restart must be faster than the regular timer interval to exceed the + # start limit when flapping. + RestartSec = "30"; + # Defer OnFailure until after retries. + RestartMode = "direct"; }; path = [ pkgs.dnsutils pkgs.gawk pkgs.iproute2 ]; scriptArgs = config.networking.fqdn; diff --git a/hostnix/elmo/system.nix b/hostnix/elmo/system.nix index 23a6aa6..d98d1ff 100644 --- a/hostnix/elmo/system.nix +++ b/hostnix/elmo/system.nix @@ -56,6 +56,11 @@ # https://wiki.archlinux.org/index.php/Systemd/Timers#MAILTO systemd.services."status-email@" = { description = "Status email for %i"; + unitConfig = { + # Throttle notifications to twice daily. + StartLimitIntervalSec = "12hr"; + StartLimitBurst = "1"; + }; serviceConfig = { Type = "oneshot"; }; -- cgit v1.3.1