Deduce gatus endpoint group from domain when possible

This commit is contained in:
SebastianStork 2025-06-20 22:17:54 +02:00
parent efe6da5582
commit dbe87bc88a
7 changed files with 11 additions and 20 deletions

View file

@ -26,9 +26,6 @@ in
}; };
}; };
custom.services.gatus.endpoints."Actual Budget" = { custom.services.gatus.endpoints."Actual Budget".url = "https://${cfg.domain}/";
group = "Private";
url = "https://${cfg.domain}/";
};
}; };
} }

View file

@ -96,14 +96,10 @@ in
custom.services.gatus.endpoints = { custom.services.gatus.endpoints = {
"Forgejo" = { "Forgejo" = {
group = "Public";
url = "https://${cfg.domain}/api/healthz"; url = "https://${cfg.domain}/api/healthz";
extraConditions = [ "[BODY].status == pass" ]; extraConditions = [ "[BODY].status == pass" ];
}; };
"Forgejo SSH" = { "Forgejo SSH".url = "ssh://${cfg.domain}";
group = "Public";
url = "ssh://${cfg.domain}";
};
}; };
}; };
} }

View file

@ -29,8 +29,8 @@ in
default = name; default = name;
}; };
group = lib.mkOption { group = lib.mkOption {
type = lib.types.str; type = lib.types.nullOr lib.types.str;
default = ""; default = null;
}; };
url = lib.mkOption { url = lib.mkOption {
type = lib.types.nonEmptyStr; type = lib.types.nonEmptyStr;
@ -101,8 +101,13 @@ in
url, url,
extraConditions, extraConditions,
}: }:
let
isPrivate = lib.hasInfix config.custom.services.tailscale.domain url;
deducedGroup = if isPrivate then "Private" else "Public";
in
{ {
inherit name group url; inherit name url;
group = if group == null then deducedGroup else group;
interval = "30s"; interval = "30s";
alerts = [ { type = "ntfy"; } ]; alerts = [ { type = "ntfy"; } ];
ssh = lib.mkIf (lib.hasPrefix "ssh" url) { ssh = lib.mkIf (lib.hasPrefix "ssh" url) {

View file

@ -81,7 +81,6 @@ in
environment.shellAliases.hedgedoc-manage-users = "sudo --user=${user} ${manage_users}"; environment.shellAliases.hedgedoc-manage-users = "sudo --user=${user} ${manage_users}";
custom.services.gatus.endpoints."Hedgedoc" = { custom.services.gatus.endpoints."Hedgedoc" = {
group = "Public";
url = "https://${cfg.domain}/_health"; url = "https://${cfg.domain}/_health";
extraConditions = [ "[BODY].ready == true" ]; extraConditions = [ "[BODY].ready == true" ];
}; };

View file

@ -31,7 +31,6 @@ in
}; };
custom.services.gatus.endpoints."IT Tools" = { custom.services.gatus.endpoints."IT Tools" = {
group = "Public";
url = "https://${cfg.domain}/health"; url = "https://${cfg.domain}/health";
extraConditions = [ "[BODY] == OK" ]; extraConditions = [ "[BODY] == OK" ];
}; };

View file

@ -74,7 +74,6 @@ in
}; };
custom.services.gatus.endpoints."Nextcloud" = { custom.services.gatus.endpoints."Nextcloud" = {
group = "Private";
url = "https://${cfg.domain}/status.php"; url = "https://${cfg.domain}/status.php";
extraConditions = [ extraConditions = [
"[BODY].installed == true" "[BODY].installed == true"

View file

@ -99,12 +99,8 @@ in
}; };
custom.services.gatus.endpoints = lib.mkIf cfg.isServer { custom.services.gatus.endpoints = lib.mkIf cfg.isServer {
"Syncthing" = { "Syncthing".url = "tcp://${config.networking.hostName}.${tailscaleCfg.domain}:22000";
group = "Private";
url = "tcp://${config.networking.hostName}.${tailscaleCfg.domain}:22000";
};
"Syncthing GUI" = { "Syncthing GUI" = {
group = "Private";
url = "https://${cfg.gui.domain}/rest/noauth/health"; url = "https://${cfg.gui.domain}/rest/noauth/health";
extraConditions = [ "[BODY].status == OK" ]; extraConditions = [ "[BODY].status == OK" ];
}; };