monitor: wait for tailscale interface
This commit is contained in:
parent
fc4a57febc
commit
3247d1edec
1 changed files with 25 additions and 1 deletions
|
@ -5,7 +5,7 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf concatStringsSep;
|
inherit (lib) mkIf getExe;
|
||||||
inherit (config.my-lib.settings) prometheusCollectors;
|
inherit (config.my-lib.settings) prometheusCollectors;
|
||||||
cfg = config.custom.prometheus.exporters;
|
cfg = config.custom.prometheus.exporters;
|
||||||
in
|
in
|
||||||
|
@ -16,6 +16,30 @@ in
|
||||||
++ (lib.optional cfg.blackbox.enable "prometheus-blackbox-exporters.service")
|
++ (lib.optional cfg.blackbox.enable "prometheus-blackbox-exporters.service")
|
||||||
++ (lib.optional config.services.caddy.enable "caddy.service");
|
++ (lib.optional config.services.caddy.enable "caddy.service");
|
||||||
|
|
||||||
|
systemd.services.tailscaled.serviceConfig.ExecStartPost =
|
||||||
|
pkgs.writers.writePython3Bin "tailscale-wait-online"
|
||||||
|
{
|
||||||
|
flakeIgnore = [
|
||||||
|
"E401" # import on one line
|
||||||
|
"E501" # line length limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
import subprocess, json, time
|
||||||
|
|
||||||
|
for _ in range(30):
|
||||||
|
status = json.loads(
|
||||||
|
subprocess.run(
|
||||||
|
["${getExe config.services.tailscale.package}", "status", "--peers=false", "--json"], capture_output=True
|
||||||
|
).stdout
|
||||||
|
)["Self"]["Online"]
|
||||||
|
if status:
|
||||||
|
exit(0)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
exit(1)
|
||||||
|
'';
|
||||||
|
|
||||||
services.prometheus.exporters.node = mkIf cfg.node.enable {
|
services.prometheus.exporters.node = mkIf cfg.node.enable {
|
||||||
enable = true;
|
enable = true;
|
||||||
enabledCollectors = [
|
enabledCollectors = [
|
||||||
|
|
Loading…
Add table
Reference in a new issue