diff --git a/check_status.sh b/check_status.sh index 4b88639..9c417e7 100644 --- a/check_status.sh +++ b/check_status.sh @@ -8,7 +8,12 @@ check_ip() { local result="" local succeeded=0 - local half_attempts=$((attempts/2)) + + result=$(nc -vz -w1 "$ip" "$port" 2>&1) + if echo "$result" | grep -q "succeeded"; then + echo "Online" + return + fi for ((i=1; i<=attempts; i++)); do result=$(nc -vz -w1 "$ip" "$port" 2>&1) @@ -18,7 +23,7 @@ check_ip() { sleep "$delay" done - if [ "$succeeded" -gt "$half_attempts" ]; then + if [ "$succeeded" -gt "$attempts/2" ]; then echo "Online" else echo "Offline"