mirror of
https://github.com/aclist/dztui.git
synced 2026-10-31 07:02:50 +01:00
Add availability checker for remote services based on ping and timeout
This commit is contained in:
1 parent
936dfe8d02
commit
f0657be289
1 file changed
+16
@@ -493,6 +493,22 @@ stale_symlinks(){
|
|||||||
unlink "$l"
|
unlink "$l"
|
||||||
done
|
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(){
|
local_latlon(){
|
||||||
if [[ -z $(command -v dig) ]]; then
|
if [[ -z $(command -v dig) ]]; then
|
||||||
local local_ip=$(curl -Ls "https://ipecho.net/plain")
|
local local_ip=$(curl -Ls "https://ipecho.net/plain")
|
||||||
|
|||||||
Reference in new issue
Block a user