From 8b49deb1d71d1f5b8f6c8c58dba5f8382724586e Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Mon, 13 Jul 2026 01:29:45 +1000 Subject: [PATCH] modularized docker health to gotify service --- hosts/docker/configuration.nix | 49 ++++++++++--------- modules/services/docker-health-to-gotify.nix | 28 +++++++++++ modules/{ => services}/nextcloud-cron-job.nix | 0 3 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 modules/services/docker-health-to-gotify.nix rename modules/{ => services}/nextcloud-cron-job.nix (100%) diff --git a/hosts/docker/configuration.nix b/hosts/docker/configuration.nix index 47973ab..0c5037a 100644 --- a/hosts/docker/configuration.nix +++ b/hosts/docker/configuration.nix @@ -27,7 +27,8 @@ in ../../modules/tailscale/enable-service.nix ../../modules/rotate-traefik-logs.nix ../../modules/raspi/mount-data.nix - ../../modules/nextcloud-cron-job.nix + ../../modules/services/nextcloud-cron-job.nix + ../../modules/services/docker-health-to-gotify.nix ]; @@ -117,30 +118,30 @@ services.rpcbind.enable = true; # 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 = "${pkgs.bash}/bin/bash /home/nixos/docker/monitoring/gotify/docker-health-to-gotify.sh"; - StandardOutput = "journal"; - StandardError = "journal"; - }; - path = with pkgs; [ docker curl coreutils gnused ]; - }; + # 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 = "${pkgs.bash}/bin/bash /home/nixos/docker/monitoring/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; - }; - }; + # systemd.timers.docker-health-to-gotify = { + # wantedBy = [ "timers.target" ]; + # timerConfig = { + # OnBootSec = "2min"; + # OnUnitActiveSec = "1min"; + # AccuracySec = "15s"; + # Persistent = true; + # }; + # }; systemd.tmpfiles.rules = [ # Create /mnt/docker diff --git a/modules/services/docker-health-to-gotify.nix b/modules/services/docker-health-to-gotify.nix new file mode 100644 index 0000000..ab1fa33 --- /dev/null +++ b/modules/services/docker-health-to-gotify.nix @@ -0,0 +1,28 @@ +{ pkgs, ... }: + +{ + 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 = "${pkgs.bash}/bin/bash /home/nixos/docker/monitoring/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; + }; + }; +} \ No newline at end of file diff --git a/modules/nextcloud-cron-job.nix b/modules/services/nextcloud-cron-job.nix similarity index 100% rename from modules/nextcloud-cron-job.nix rename to modules/services/nextcloud-cron-job.nix