mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 16:21:34 +01:00
Add gatus module
This commit is contained in:
parent
0183a7545c
commit
f81d169e64
1 changed files with 121 additions and 0 deletions
121
modules/system/services/gatus.nix
Normal file
121
modules/system/services/gatus.nix
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.gatus;
|
||||
|
||||
tailscaleDomain = config.custom.services.tailscale.domain;
|
||||
in
|
||||
{
|
||||
options.custom.services.gatus = {
|
||||
enable = lib.mkEnableOption "";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 8080;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
meta.ports.list = [ cfg.port ];
|
||||
|
||||
services.gatus = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
web.port = cfg.port;
|
||||
|
||||
storage = {
|
||||
type = "sqlite";
|
||||
path = "/var/lib/gatus/data.db";
|
||||
};
|
||||
|
||||
connectivity.checker.target = "1.1.1.1:53";
|
||||
|
||||
alerting = {
|
||||
ntfy = {
|
||||
topic = "uptime";
|
||||
url = "https://alerts.${tailscaleDomain}";
|
||||
click = "https://${cfg.domain}";
|
||||
default-alert = {
|
||||
enable = true;
|
||||
failure-threshold = 4;
|
||||
success-threshold = 2;
|
||||
send-on-resolved = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
endpoints =
|
||||
let
|
||||
mkHttpCheck =
|
||||
{
|
||||
name,
|
||||
url,
|
||||
conditions ? [ ],
|
||||
}:
|
||||
{
|
||||
inherit name url;
|
||||
conditions = [ "[STATUS] == 200" ] ++ conditions;
|
||||
interval = "30s";
|
||||
alerts = [ { type = "ntfy"; } ];
|
||||
};
|
||||
in
|
||||
[
|
||||
{
|
||||
name = "Syncthing";
|
||||
url = "tcp://alto.${tailscaleDomain}:22000";
|
||||
conditions = [ "[CONNECTED] == true" ];
|
||||
interval = "30s";
|
||||
alerts = [ { type = "ntfy"; } ];
|
||||
}
|
||||
(mkHttpCheck {
|
||||
name = "Syncthing GUI";
|
||||
url = "https://syncthing.${tailscaleDomain}/rest/noauth/health";
|
||||
conditions = [ "[BODY].status == OK" ];
|
||||
})
|
||||
(mkHttpCheck {
|
||||
name = "Nextcloud";
|
||||
url = "https://cloud.${tailscaleDomain}/status.php";
|
||||
conditions = [
|
||||
"[BODY].installed == true"
|
||||
"[BODY].maintenance == false"
|
||||
"[BODY].needsDbUpgrade == false"
|
||||
];
|
||||
})
|
||||
(mkHttpCheck {
|
||||
name = "Actual Budget";
|
||||
url = "https://budget.${tailscaleDomain}/";
|
||||
})
|
||||
(mkHttpCheck {
|
||||
name = "Hedgedoc";
|
||||
url = "https://docs.sprouted.cloud/_health";
|
||||
conditions = [ "[BODY].ready == true" ];
|
||||
})
|
||||
(mkHttpCheck {
|
||||
name = "Forgejo";
|
||||
url = "https://git.sstork.dev/api/healthz";
|
||||
conditions = [ "[BODY].status == pass" ];
|
||||
})
|
||||
{
|
||||
name = "Forgejo SSH";
|
||||
url = "ssh://git.sstork.dev";
|
||||
ssh = {
|
||||
username = "";
|
||||
password = "";
|
||||
};
|
||||
conditions = [ "[CONNECTED] == true" ];
|
||||
interval = "30s";
|
||||
alerts = [ { type = "ntfy"; } ];
|
||||
}
|
||||
(mkHttpCheck {
|
||||
name = "Ntfy";
|
||||
url = "https://alerts.${tailscaleDomain}/v1/health";
|
||||
conditions = [ "[BODY].healthy == true" ];
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue