diff --git a/hosts/cumulus/default.nix b/hosts/cumulus/default.nix index f64f04f..a3710b8 100644 --- a/hosts/cumulus/default.nix +++ b/hosts/cumulus/default.nix @@ -18,6 +18,15 @@ gatus = { enable = true; domain = "status.${config.custom.services.tailscale.domain}"; + endpoints = { + "status".group = "Monitoring"; + "alerts" = { + group = "Monitoring"; + appendPath = "/v1/health"; + extraConditions = [ "[BODY].healthy == true" ]; + }; + "git ssh".url = "ssh://git.sstork.dev"; + }; }; ntfy = { enable = true; diff --git a/modules/system/services/actualbudget/default.nix b/modules/system/services/actualbudget/default.nix index e7eb63e..cbdeaae 100644 --- a/modules/system/services/actualbudget/default.nix +++ b/modules/system/services/actualbudget/default.nix @@ -25,7 +25,5 @@ in inherit (cfg) port; }; }; - - custom.services.gatus.endpoints."Actual Budget".url = "https://${cfg.domain}/"; }; } diff --git a/modules/system/services/forgejo/default.nix b/modules/system/services/forgejo/default.nix index 853a7e7..96cb536 100644 --- a/modules/system/services/forgejo/default.nix +++ b/modules/system/services/forgejo/default.nix @@ -93,13 +93,5 @@ in "d ${config.services.forgejo.customDir}/public 750 ${user} ${group} - -" "L+ ${config.services.forgejo.customDir}/public/robots.txt 750 - - - ${disallow-all-robots}" ]; - - custom.services.gatus.endpoints = { - "Forgejo" = { - url = "https://${cfg.domain}/api/healthz"; - extraConditions = [ "[BODY].status == pass" ]; - }; - "Forgejo SSH".url = "ssh://${cfg.domain}"; - }; }; } diff --git a/modules/system/services/gatus.nix b/modules/system/services/gatus.nix index d77e8b7..ede0bc0 100644 --- a/modules/system/services/gatus.nix +++ b/modules/system/services/gatus.nix @@ -1,9 +1,4 @@ -{ - config, - self, - lib, - ... -}: +{ config, lib, ... }: let cfg = config.custom.services.gatus; in @@ -36,6 +31,10 @@ in type = lib.types.nonEmptyStr; default = ""; }; + appendPath = lib.mkOption { + type = lib.types.str; + default = ""; + }; extraConditions = lib.mkOption { type = lib.types.listOf lib.types.nonEmptyStr; default = [ ]; @@ -58,6 +57,14 @@ in ''; }; + custom.services.gatus.endpoints = + let + getSubdomain = domain: domain |> lib.splitString "." |> lib.head; + in + config.meta.domains.globalList + |> lib.map (domain: lib.nameValuePair (getSubdomain domain) { url = "https://${domain}"; }) + |> lib.listToAttrs; + services.gatus = { enable = true; environmentFile = config.sops.templates."gatus.env".path; @@ -99,6 +106,7 @@ in name, group, url, + appendPath, extraConditions, }: let @@ -106,9 +114,9 @@ in deducedGroup = if isPrivate then "Private" else "Public"; in { - inherit name url; - group = if group == null then deducedGroup else group; - interval = "30s"; + inherit name; + group = if group != null then group else deducedGroup; + url = url + appendPath; alerts = [ { type = "ntfy"; } ]; ssh = lib.mkIf (lib.hasPrefix "ssh" url) { username = ""; @@ -125,20 +133,14 @@ in in [ { - name = "Healthchecks.io"; + name = "healthchecks.io"; group = "Monitoring"; - url = "https://hc-ping.com/\${HEALTHCHECKS_PING_KEY}/gatus-uptime?create=1"; + url = "https://hc-ping.com/\${HEALTHCHECKS_PING_KEY}/${config.networking.hostName}-gatus-uptime?create=1"; interval = "2h"; conditions = [ "[STATUS] == 200" ]; } ] - ++ ( - self.nixosConfigurations - |> lib.mapAttrsToList (_: value: value.config.custom.services.gatus.endpoints) - |> lib.map (entry: lib.mapAttrsToList (_: value: value) entry) - |> lib.concatLists - |> lib.map (entry: mkEndpoint entry) - ); + ++ (cfg.endpoints |> lib.mapAttrsToList (_: value: value) |> lib.map (entry: mkEndpoint entry)); }; }; }; diff --git a/modules/system/services/hedgedoc/default.nix b/modules/system/services/hedgedoc/default.nix index 70374e1..d144347 100644 --- a/modules/system/services/hedgedoc/default.nix +++ b/modules/system/services/hedgedoc/default.nix @@ -79,10 +79,5 @@ in }; environment.shellAliases.hedgedoc-manage-users = "sudo --user=${user} ${manage_users}"; - - custom.services.gatus.endpoints."Hedgedoc" = { - url = "https://${cfg.domain}/_health"; - extraConditions = [ "[BODY].ready == true" ]; - }; }; } diff --git a/modules/system/services/it-tools.nix b/modules/system/services/it-tools.nix index a8af760..3aca856 100644 --- a/modules/system/services/it-tools.nix +++ b/modules/system/services/it-tools.nix @@ -29,10 +29,5 @@ in root = "${pkgs.it-tools}/lib"; configuration.general.health = true; }; - - custom.services.gatus.endpoints."IT Tools" = { - url = "https://${cfg.domain}/health"; - extraConditions = [ "[BODY] == OK" ]; - }; }; } diff --git a/modules/system/services/nextcloud/default.nix b/modules/system/services/nextcloud/default.nix index 90b437e..0300909 100644 --- a/modules/system/services/nextcloud/default.nix +++ b/modules/system/services/nextcloud/default.nix @@ -72,14 +72,5 @@ in }; }; }; - - custom.services.gatus.endpoints."Nextcloud" = { - url = "https://${cfg.domain}/status.php"; - extraConditions = [ - "[BODY].installed == true" - "[BODY].maintenance == false" - "[BODY].needsDbUpgrade == false" - ]; - }; }; } diff --git a/modules/system/services/ntfy.nix b/modules/system/services/ntfy.nix index 1cb30e7..b86f47a 100644 --- a/modules/system/services/ntfy.nix +++ b/modules/system/services/ntfy.nix @@ -27,11 +27,5 @@ in web-root = "disable"; }; }; - - custom.services.gatus.endpoints."Ntfy" = { - group = "Monitoring"; - url = "https://${cfg.domain}/v1/health"; - extraConditions = [ "[BODY].healthy == true" ]; - }; }; } diff --git a/modules/system/services/syncthing/default.nix b/modules/system/services/syncthing/default.nix index 1e7f015..5cea27a 100644 --- a/modules/system/services/syncthing/default.nix +++ b/modules/system/services/syncthing/default.nix @@ -97,13 +97,5 @@ in }; }; }; - - custom.services.gatus.endpoints = lib.mkIf cfg.isServer { - "Syncthing".url = "tcp://${config.networking.hostName}.${tailscaleCfg.domain}:22000"; - "Syncthing GUI" = { - url = "https://${cfg.gui.domain}/rest/noauth/health"; - extraConditions = [ "[BODY].status == OK" ]; - }; - }; }; }