mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 15:11:34 +01:00
Declare gatus endpoints in each of their respective modules
This commit is contained in:
parent
d6245fada0
commit
7a9796e02c
7 changed files with 104 additions and 77 deletions
|
|
@ -25,5 +25,10 @@ in
|
|||
inherit (cfg) port;
|
||||
};
|
||||
};
|
||||
|
||||
custom.services.gatus.endpoints."Actual Budget" = {
|
||||
group = "Private";
|
||||
url = "https://${cfg.domain}/";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,5 +93,17 @@ 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" = {
|
||||
group = "Public";
|
||||
url = "https://${cfg.domain}/api/healthz";
|
||||
extraConditions = [ "[BODY].status == pass" ];
|
||||
};
|
||||
"Forgejo SSH" = {
|
||||
group = "Public";
|
||||
url = "ssh://${cfg.domain}";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
config,
|
||||
self,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.gatus;
|
||||
|
||||
|
|
@ -15,6 +20,34 @@ in
|
|||
type = lib.types.port;
|
||||
default = 8080;
|
||||
};
|
||||
endpoints = lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule (
|
||||
{ name, ... }:
|
||||
{
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = name;
|
||||
};
|
||||
group = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
};
|
||||
url = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
extraConditions = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.nonEmptyStr;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
|
@ -54,82 +87,25 @@ in
|
|||
};
|
||||
|
||||
endpoints =
|
||||
let
|
||||
mkHttpCheck =
|
||||
{
|
||||
name,
|
||||
group,
|
||||
url,
|
||||
conditions ? [ ],
|
||||
}:
|
||||
{
|
||||
inherit name group url;
|
||||
conditions = [ "[STATUS] == 200" ] ++ conditions;
|
||||
interval = "30s";
|
||||
alerts = [ { type = "ntfy"; } ];
|
||||
};
|
||||
in
|
||||
[
|
||||
{
|
||||
name = "Syncthing";
|
||||
group = "Private";
|
||||
url = "tcp://alto.${tailscaleDomain}:22000";
|
||||
conditions = [ "[CONNECTED] == true" ];
|
||||
interval = "30s";
|
||||
alerts = [ { type = "ntfy"; } ];
|
||||
}
|
||||
(mkHttpCheck {
|
||||
name = "Syncthing GUI";
|
||||
group = "Private";
|
||||
url = "https://syncthing.${tailscaleDomain}/rest/noauth/health";
|
||||
conditions = [ "[BODY].status == OK" ];
|
||||
})
|
||||
(mkHttpCheck {
|
||||
name = "Nextcloud";
|
||||
group = "Private";
|
||||
url = "https://cloud.${tailscaleDomain}/status.php";
|
||||
conditions = [
|
||||
"[BODY].installed == true"
|
||||
"[BODY].maintenance == false"
|
||||
"[BODY].needsDbUpgrade == false"
|
||||
];
|
||||
})
|
||||
(mkHttpCheck {
|
||||
name = "Actual Budget";
|
||||
group = "Private";
|
||||
url = "https://budget.${tailscaleDomain}/";
|
||||
})
|
||||
(mkHttpCheck {
|
||||
name = "Hedgedoc";
|
||||
group = "Public";
|
||||
url = "https://docs.sprouted.cloud/_health";
|
||||
conditions = [ "[BODY].ready == true" ];
|
||||
})
|
||||
(mkHttpCheck {
|
||||
name = "Forgejo";
|
||||
group = "Public";
|
||||
url = "https://git.sstork.dev/api/healthz";
|
||||
conditions = [ "[BODY].status == pass" ];
|
||||
})
|
||||
{
|
||||
name = "Forgejo SSH";
|
||||
group = "Public";
|
||||
url = "ssh://git.sstork.dev";
|
||||
ssh = {
|
||||
username = "";
|
||||
password = "";
|
||||
};
|
||||
conditions = [ "[CONNECTED] == true" ];
|
||||
interval = "30s";
|
||||
alerts = [ { type = "ntfy"; } ];
|
||||
}
|
||||
(mkHttpCheck {
|
||||
name = "Ntfy";
|
||||
group = "Monitoring";
|
||||
url = "https://alerts.${tailscaleDomain}/v1/health";
|
||||
conditions = [ "[BODY].healthy == true" ];
|
||||
})
|
||||
];
|
||||
self.nixosConfigurations
|
||||
|> lib.mapAttrsToList (_: value: value.config.custom.services.gatus.endpoints)
|
||||
|> lib.map (entry: lib.mapAttrsToList (_: value: value) entry)
|
||||
|> lib.flatten
|
||||
|> lib.map (value: {
|
||||
inherit (value) name group url;
|
||||
interval = "30s";
|
||||
alerts = [ { type = "ntfy"; } ];
|
||||
ssh = lib.mkIf (lib.hasPrefix "ssh" value.url) {
|
||||
username = "";
|
||||
password = "";
|
||||
};
|
||||
conditions = lib.flatten [
|
||||
value.extraConditions
|
||||
(lib.optional (lib.hasPrefix "http" value.url) "[STATUS] == 200")
|
||||
(lib.optional (lib.hasPrefix "tcp" value.url) "[CONNECTED] == true")
|
||||
(lib.optional (lib.hasPrefix "ssh" value.url) "[CONNECTED] == true")
|
||||
];
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,5 +79,11 @@ in
|
|||
};
|
||||
|
||||
environment.shellAliases.hedgedoc-manage-users = "sudo --user=${user} ${manage_users}";
|
||||
|
||||
custom.services.gatus.endpoints."Hedgedoc" = {
|
||||
group = "Public";
|
||||
url = "https://${cfg.domain}/_health";
|
||||
extraConditions = [ "[BODY].ready == true" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,5 +72,15 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
custom.services.gatus.endpoints."Nextcloud" = {
|
||||
group = "Private";
|
||||
url = "https://${cfg.domain}/status.php";
|
||||
extraConditions = [
|
||||
"[BODY].installed == true"
|
||||
"[BODY].maintenance == false"
|
||||
"[BODY].needsDbUpgrade == false"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,5 +27,11 @@ in
|
|||
web-root = "disable";
|
||||
};
|
||||
};
|
||||
|
||||
custom.services.gatus.endpoints."Ntfy" = {
|
||||
group = "Monitoring";
|
||||
url = "https://${cfg.domain}/v1/health";
|
||||
extraConditions = [ "[BODY].healthy == true" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,5 +97,17 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
custom.services.gatus.endpoints = lib.mkIf cfg.isServer {
|
||||
"Syncthing" = {
|
||||
group = "Private";
|
||||
url = "tcp://${config.networking.hostName}.${tailscaleCfg.domain}:22000";
|
||||
};
|
||||
"Syncthing GUI" = {
|
||||
group = "Private";
|
||||
url = "https://${cfg.gui.domain}/rest/noauth/health";
|
||||
extraConditions = [ "[BODY].status == OK" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue