mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
fix(monitoring): websocket status
This commit is contained in:
parent
f1d249d4c0
commit
17d1f5147e
4 changed files with 51 additions and 7 deletions
|
|
@ -8,7 +8,16 @@ in {
|
|||
config.exports.services.freepbx = {config, ...}: {
|
||||
displayName = mkAlmostOptionDefault "FreePBX";
|
||||
id = mkAlmostOptionDefault "pbx";
|
||||
ports = {
|
||||
ports = let
|
||||
ucpGtatus = {
|
||||
client.network = mkAlmostOptionDefault "ip4";
|
||||
http = {
|
||||
websocket.enable = mkAlmostOptionDefault true;
|
||||
path = mkAlmostOptionDefault "/socket.io/?transport=websocket";
|
||||
statusCondition = mkAlmostOptionDefault "[BODY] == pat(*\"sid\":*)";
|
||||
};
|
||||
};
|
||||
in {
|
||||
http = {
|
||||
displayName = mkAlmostOptionDefault null;
|
||||
port = mkAlmostOptionDefault 80;
|
||||
|
|
@ -25,12 +34,13 @@ in {
|
|||
displayName = mkAlmostOptionDefault "UCP";
|
||||
status = {
|
||||
enable = mkAlmostOptionDefault config.ports.http.status.enable;
|
||||
gatus.client.network = mkAlmostOptionDefault "ip4";
|
||||
gatus = ucpGtatus;
|
||||
};
|
||||
};
|
||||
ucp-ssl = {
|
||||
port = mkAlmostOptionDefault 8003;
|
||||
protocol = "https";
|
||||
status.gatus = ucpGtatus;
|
||||
};
|
||||
asterisk = {
|
||||
port = mkAlmostOptionDefault 8088;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ let
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) unmerged;
|
||||
inherit (gensokyo-zone.lib) mapOptionDefaults unmerged;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.modules) mkIf mkMerge mkOptionDefault;
|
||||
in {
|
||||
|
|
@ -43,6 +43,13 @@ let
|
|||
statusCondition = mkOption {
|
||||
type = nullOr str;
|
||||
};
|
||||
websocket = {
|
||||
enable = mkEnableOption "ws://";
|
||||
status = mkOption {
|
||||
type = int;
|
||||
default = 200;
|
||||
};
|
||||
};
|
||||
};
|
||||
protocol = mkOption {
|
||||
type = str;
|
||||
|
|
@ -56,8 +63,22 @@ let
|
|||
config = {
|
||||
status.gatus = let
|
||||
cfg = config.status.gatus;
|
||||
useWebsocket = cfg.http.websocket.enable && cfg.http.websocket.status == 200;
|
||||
mockWebsocket = cfg.http.websocket.enable && cfg.http.websocket.status != 200;
|
||||
protocolWs =
|
||||
if config.ssl || config.protocol == "https"
|
||||
then "wss"
|
||||
else "ws";
|
||||
protocolHttp =
|
||||
if config.ssl || config.protocol == "https"
|
||||
then "https"
|
||||
else "http";
|
||||
defaultProtocol =
|
||||
if config.protocol != null
|
||||
if useWebsocket
|
||||
then mkOptionDefault protocolWs
|
||||
else if cfg.http.websocket.enable
|
||||
then mkOptionDefault protocolHttp
|
||||
else if config.protocol != null
|
||||
then mkOptionDefault config.protocol
|
||||
else if config.starttls
|
||||
then mkOptionDefault "starttls"
|
||||
|
|
@ -69,7 +90,9 @@ let
|
|||
in {
|
||||
protocol = defaultProtocol;
|
||||
http.statusCondition = mkOptionDefault (
|
||||
if cfg.protocol == "http" || cfg.protocol == "https"
|
||||
if mockWebsocket
|
||||
then "[STATUS] == ${toString cfg.http.websocket.status}"
|
||||
else if cfg.protocol == "http" || cfg.protocol == "https"
|
||||
then "[STATUS] == 200"
|
||||
else null
|
||||
);
|
||||
|
|
@ -91,6 +114,14 @@ let
|
|||
"[DNS_RCODE] == NOERROR"
|
||||
];
|
||||
})
|
||||
(mkIf mockWebsocket {
|
||||
headers = mapOptionDefaults {
|
||||
Connection = "Upgrade";
|
||||
Upgrade = "websocket";
|
||||
Sec-WebSocket-Version = "13";
|
||||
Sec-WebSocket-Key = "SGVsbG8sIHdvcmxkIQ==";
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ in {
|
|||
displayName = mkAlmostOptionDefault "WebSocket";
|
||||
status = {
|
||||
enable = mkAlmostOptionDefault true;
|
||||
gatus.protocol = "ws";
|
||||
gatus.http.websocket = {
|
||||
enable = mkAlmostOptionDefault true;
|
||||
status = mkAlmostOptionDefault 401;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue