diff --git a/hosts/docker/configuration.nix b/hosts/docker/configuration.nix index d0ea7d3..30c1851 100644 --- a/hosts/docker/configuration.nix +++ b/hosts/docker/configuration.nix @@ -82,6 +82,35 @@ systemd.timers.update-containers = { }; }; +# Create Gotify Docker monitoring script task +{ + systemd.services.docker-health-to-gotify = { + description = "Alert Gotify when Docker containers become unhealthy"; + after = [ "docker.service" ]; + serviceConfig = { + Type = "oneshot"; + # Run as root so it can read /etc/secrets and access docker socket + # User = "root"; + #EnvironmentFile = "-/etc/secrets/docker-health-alert.env"; + ExecStart = "mnt/docker-persistent-data/docker/gotify/docker-health-to-gotify.sh"; + StandardOutput = "journal"; + StandardError = "journal"; + }; + path = with pkgs; [ docker curl coreutils gnused ]; + }; + + systemd.timers.docker-health-to-gotify = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnBootSec = "2min"; + OnUnitActiveSec = "1min"; + AccuracySec = "15s"; + Persistent = true; + }; + }; +} + + #Add sym links to data on users home folder system.userActivationScripts.createDockerSymlink.text = '' ln -sf /mnt/docker-persistent-data/docker /home/nixos/docker