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, ...}: {
|
config.exports.services.freepbx = {config, ...}: {
|
||||||
displayName = mkAlmostOptionDefault "FreePBX";
|
displayName = mkAlmostOptionDefault "FreePBX";
|
||||||
id = mkAlmostOptionDefault "pbx";
|
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 = {
|
http = {
|
||||||
displayName = mkAlmostOptionDefault null;
|
displayName = mkAlmostOptionDefault null;
|
||||||
port = mkAlmostOptionDefault 80;
|
port = mkAlmostOptionDefault 80;
|
||||||
|
|
@ -25,12 +34,13 @@ in {
|
||||||
displayName = mkAlmostOptionDefault "UCP";
|
displayName = mkAlmostOptionDefault "UCP";
|
||||||
status = {
|
status = {
|
||||||
enable = mkAlmostOptionDefault config.ports.http.status.enable;
|
enable = mkAlmostOptionDefault config.ports.http.status.enable;
|
||||||
gatus.client.network = mkAlmostOptionDefault "ip4";
|
gatus = ucpGtatus;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
ucp-ssl = {
|
ucp-ssl = {
|
||||||
port = mkAlmostOptionDefault 8003;
|
port = mkAlmostOptionDefault 8003;
|
||||||
protocol = "https";
|
protocol = "https";
|
||||||
|
status.gatus = ucpGtatus;
|
||||||
};
|
};
|
||||||
asterisk = {
|
asterisk = {
|
||||||
port = mkAlmostOptionDefault 8088;
|
port = mkAlmostOptionDefault 8088;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ let
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (gensokyo-zone.lib) unmerged;
|
inherit (gensokyo-zone.lib) mapOptionDefaults unmerged;
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.modules) mkIf mkMerge mkOptionDefault;
|
inherit (lib.modules) mkIf mkMerge mkOptionDefault;
|
||||||
in {
|
in {
|
||||||
|
|
@ -43,6 +43,13 @@ let
|
||||||
statusCondition = mkOption {
|
statusCondition = mkOption {
|
||||||
type = nullOr str;
|
type = nullOr str;
|
||||||
};
|
};
|
||||||
|
websocket = {
|
||||||
|
enable = mkEnableOption "ws://";
|
||||||
|
status = mkOption {
|
||||||
|
type = int;
|
||||||
|
default = 200;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
protocol = mkOption {
|
protocol = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
|
|
@ -56,8 +63,22 @@ let
|
||||||
config = {
|
config = {
|
||||||
status.gatus = let
|
status.gatus = let
|
||||||
cfg = config.status.gatus;
|
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 =
|
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
|
then mkOptionDefault config.protocol
|
||||||
else if config.starttls
|
else if config.starttls
|
||||||
then mkOptionDefault "starttls"
|
then mkOptionDefault "starttls"
|
||||||
|
|
@ -69,7 +90,9 @@ let
|
||||||
in {
|
in {
|
||||||
protocol = defaultProtocol;
|
protocol = defaultProtocol;
|
||||||
http.statusCondition = mkOptionDefault (
|
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"
|
then "[STATUS] == 200"
|
||||||
else null
|
else null
|
||||||
);
|
);
|
||||||
|
|
@ -91,6 +114,14 @@ let
|
||||||
"[DNS_RCODE] == NOERROR"
|
"[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";
|
displayName = mkAlmostOptionDefault "WebSocket";
|
||||||
status = {
|
status = {
|
||||||
enable = mkAlmostOptionDefault true;
|
enable = mkAlmostOptionDefault true;
|
||||||
gatus.protocol = "ws";
|
gatus.http.websocket = {
|
||||||
|
enable = mkAlmostOptionDefault true;
|
||||||
|
status = mkAlmostOptionDefault 401;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (gensokyo-zone) systems;
|
inherit (gensokyo-zone) systems;
|
||||||
inherit (gensokyo-zone.lib) mkAddress6 mkAlmostOptionDefault unmerged;
|
inherit (gensokyo-zone.lib) mkAddress6 mkAlmostOptionDefault mapOptionDefaults unmerged;
|
||||||
inherit (lib.modules) mkIf mkMerge mkDefault mkOptionDefault;
|
inherit (lib.modules) mkIf mkMerge mkDefault mkOptionDefault;
|
||||||
inherit (lib.attrsets) attrValues nameValuePair listToAttrs;
|
inherit (lib.attrsets) attrValues nameValuePair listToAttrs;
|
||||||
inherit (lib.lists) filter length optional concatMap;
|
inherit (lib.lists) filter length optional concatMap;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue