infrastructure/machines/nixos/rescue01/uptime-kuma.nix

163 lines
3.3 KiB
Nix
Raw Normal View History

{
2024-04-23 22:02:04 +02:00
config,
lib,
meta,
nodes,
sources,
...
}:
2024-03-28 16:25:29 +01:00
let
2024-04-23 22:02:04 +02:00
inherit (lib)
concatLists
filterAttrs
2024-04-23 22:02:04 +02:00
mapAttrsToList
mkForce
mkMerge
;
inherit (config.statelessUptimeKuma.lib)
pingProbesFromHive
fromHive
httpProbesFromConfig
probesWithTag
;
2024-04-23 22:02:04 +02:00
serverNodes = filterAttrs (name: _: meta.nodes.${name}.nixpkgs.system == "nixos") nodes;
2024-04-23 22:02:04 +02:00
probesCfg = config.statelessUptimeKuma.probesConfig;
mkMonitors = name: builtins.attrNames (probesWithTag { inherit name; } probesCfg);
2024-03-28 16:25:29 +01:00
host = "status.dgnum.eu";
port = 3001;
httpExcludes =
[
"localhost"
"ens.cal.dgnum.eu"
"luj-current.cal.dgnum.eu"
"s3.dgnum.eu"
"cdn.dgnum.eu"
"saml-idp.dgnum.eu"
"status.dgnum.eu"
"radius.dgnum.eu"
]
++ (concatLists (mapAttrsToList (_: { config, ... }: config.dgn-redirections.retired) serverNodes));
extraProbes = {
monitors = {
"prometheus.dgnum.eu" = {
2024-04-23 22:02:04 +02:00
type = mkForce "http";
accepted_statuscodes = [ "401" ];
};
2024-04-23 22:02:04 +02:00
"ollama01.beta.dgnum.eu" = {
type = mkForce "http";
accepted_statuscodes = [ "401" ];
};
"s3-admin.dgnum.eu" = {
type = mkForce "http";
accepted_statuscodes = [ "400" ];
};
"api.meet.dgnum.eu" = {
keyword = "Crab Fit API";
};
};
};
status_pages = {
"dgnum" = {
title = "DGNum";
description = "Etat de l'infra de la DGNum";
showTags = true;
publicGroupList = [
{
name = "Services";
weight = 1;
2024-04-23 22:02:04 +02:00
monitorList = mkMonitors "Service";
}
{
name = "Serveurs";
weight = 2;
2024-04-23 22:02:04 +02:00
monitorList = mkMonitors "Ping";
}
{
name = "VPN Interne";
weight = 2;
2024-04-23 22:02:04 +02:00
monitorList = mkMonitors "VPN";
}
];
};
};
pingProbes = pingProbesFromHive {
nodes = serverNodes;
mkHost = _: config: config.networking.fqdn;
tags = [ { name = "Ping"; } ];
excludes = [
"geo01"
"geo02"
"rescue01"
];
};
vpnProbes = pingProbesFromHive {
nodes = serverNodes;
prefix = "VPN - ";
mkHost = node: _: "${node}.dgnum";
tags = [ { name = "VPN"; } ];
excludes = [
"rescue01"
"web02"
];
};
httpProbes = fromHive {
nodes = serverNodes;
builder =
_: module:
httpProbesFromConfig {
inherit (module) config;
tags = [
{
name = "Host";
value = module.config.networking.fqdn;
}
{ name = "Service"; }
];
excludes = httpExcludes;
};
};
2024-03-28 16:25:29 +01:00
in
{
imports = [ (sources.stateless-uptime-kuma + "/nixos/module.nix") ];
nixpkgs.overlays = [ (import (sources.stateless-uptime-kuma + "/overlay.nix")) ];
2024-04-23 22:02:04 +02:00
2024-03-28 16:25:29 +01:00
services.uptime-kuma.enable = true;
dgn-web.simpleProxies.uptime-kuma = {
inherit host port;
proxyWebsockets = true;
2024-03-28 16:25:29 +01:00
};
statelessUptimeKuma = {
2024-04-23 22:02:04 +02:00
probesConfig = mkMerge [
pingProbes
httpProbes
extraProbes
vpnProbes
{ inherit status_pages; }
];
2024-04-23 22:02:04 +02:00
extraFlags = [ "-s" ];
host = "http://localhost:${builtins.toString port}/";
username = "dgnum";
passwordFile = config.age.secrets."stateless-uptime-kuma-password".path;
enableService = true;
};
2024-03-28 16:25:29 +01:00
}