From f0657be289575a17b94c8cdcb9f6e11b923c75f1 Mon Sep 17 00:00:00 2001 From: Gergely Koloszar Date: Thu, 16 Oct 2025 20:50:42 +0200 Subject: [PATCH] Add availability checker for remote services based on ping and timeout --- dzgui.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dzgui.sh b/dzgui.sh index 33fb0d1..8585251 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -493,6 +493,22 @@ stale_symlinks(){ unlink "$l" done } + +check_availability() { + if [[ -z $1 ]]; then + return 1 + fi + local url=$1 + local timeout_sec="3" + if [[ $2 ]]; then + timeout_sec=$2 + fi + if ! ping -w "$timeout_sec" "$url"; then + logger WARN "Failed to reach $url, service may be down." + return 1 + fi +} + local_latlon(){ if [[ -z $(command -v dig) ]]; then local local_ip=$(curl -Ls "https://ipecho.net/plain")