|
@@ -9,81 +9,78 @@ local commandname="MONITOR"
|
|
|
local commandaction="Monitor"
|
|
local commandaction="Monitor"
|
|
|
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
|
|
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
|
|
|
|
|
|
|
|
-if [ "${gsquery}" == "yes" ]; then
|
|
|
|
|
|
|
+# Downloads gsquery.py if missing
|
|
|
|
|
+if [ ! -f "${functionsdir}/gsquery.py" ]; then
|
|
|
|
|
+ fn_fetch_file_github "lgsm/functions" "gsquery.py" "${functionsdir}" "chmodx" "norun" "noforce" "nomd5"
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
- # Downloads gsquery.py if missing
|
|
|
|
|
- if [ ! -f "${functionsdir}/gsquery.py" ]; then
|
|
|
|
|
- fn_fetch_file_github "lgsm/functions" "gsquery.py" "${functionsdir}" "chmodx" "norun" "noforce" "nomd5"
|
|
|
|
|
- fi
|
|
|
|
|
|
|
+info_config.sh
|
|
|
|
|
|
|
|
- info_config.sh
|
|
|
|
|
|
|
+if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
|
|
|
|
|
+ port=$((port + 1))
|
|
|
|
|
+elif [ "${engine}" == "realvirtuality" ]; then
|
|
|
|
|
+ port=$((port + 1))
|
|
|
|
|
+elif [ "${engine}" == "spark" ]; then
|
|
|
|
|
+ port=$((port + 1))
|
|
|
|
|
+elif [ "${engine}" == "idtech3_ql" ]; then
|
|
|
|
|
+ engine="quakelive"
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
- if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
|
|
|
|
|
- port=$((port + 1))
|
|
|
|
|
- elif [ "${engine}" == "realvirtuality" ]; then
|
|
|
|
|
- port=$((port + 1))
|
|
|
|
|
- elif [ "${engine}" == "spark" ]; then
|
|
|
|
|
- port=$((port + 1))
|
|
|
|
|
- elif [ "${engine}" == "idtech3_ql" ]; then
|
|
|
|
|
- engine="quakelive"
|
|
|
|
|
- fi
|
|
|
|
|
|
|
+if [ -n "${queryport}" ]; then
|
|
|
|
|
+ port="${queryport}"
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
- if [ -n "${queryport}" ]; then
|
|
|
|
|
- port="${queryport}"
|
|
|
|
|
- fi
|
|
|
|
|
|
|
+fn_print_info "Querying port: gsquery.py enabled"
|
|
|
|
|
+fn_script_log_info "Querying port: gsquery.py enabled"
|
|
|
|
|
+sleep 1
|
|
|
|
|
|
|
|
- fn_print_info "Querying port: gsquery.py enabled"
|
|
|
|
|
- fn_script_log_info "Querying port: gsquery.py enabled"
|
|
|
|
|
- sleep 1
|
|
|
|
|
|
|
+# Will query up to 4 times every 15 seconds.
|
|
|
|
|
+# Servers changing map can return a failure.
|
|
|
|
|
+# Will Wait up to 60 seconds to confirm server is down giving server time to change map.
|
|
|
|
|
+totalseconds=0
|
|
|
|
|
+for queryattempt in {1..5}; do
|
|
|
|
|
+ fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : "
|
|
|
|
|
+ fn_print_querying_eol
|
|
|
|
|
+ fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING"
|
|
|
|
|
|
|
|
- # Will query up to 4 times every 15 seconds.
|
|
|
|
|
- # Servers changing map can return a failure.
|
|
|
|
|
- # Will Wait up to 60 seconds to confirm server is down giving server time to change map.
|
|
|
|
|
- totalseconds=0
|
|
|
|
|
- for queryattempt in {1..5}; do
|
|
|
|
|
- fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : "
|
|
|
|
|
- fn_print_querying_eol
|
|
|
|
|
- fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING"
|
|
|
|
|
|
|
+ gsquerycmd=$("${functionsdir}"/gsquery.py -a "${ip}" -p "${port}" -e "${engine}" 2>&1)
|
|
|
|
|
+ exitcode=$?
|
|
|
|
|
|
|
|
- gsquerycmd=$("${functionsdir}"/gsquery.py -a "${ip}" -p "${port}" -e "${engine}" 2>&1)
|
|
|
|
|
- exitcode=$?
|
|
|
|
|
|
|
+ sleep 1
|
|
|
|
|
+ if [ "${exitcode}" == "0" ]; then
|
|
|
|
|
+ # Server OK
|
|
|
|
|
+ fn_print_ok "Querying port: ${ip}:${port} : ${queryattempt} : "
|
|
|
|
|
+ fn_print_ok_eol_nl
|
|
|
|
|
+ fn_script_log_pass "Querying port: ${ip}:${port} : ${queryattempt} : OK"
|
|
|
|
|
+ exitcode=0
|
|
|
|
|
+ break
|
|
|
|
|
+ else
|
|
|
|
|
+ # Server failed query
|
|
|
|
|
+ fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}"
|
|
|
|
|
|
|
|
- sleep 1
|
|
|
|
|
- if [ "${exitcode}" == "0" ]; then
|
|
|
|
|
- # Server OK
|
|
|
|
|
- fn_print_ok "Querying port: ${ip}:${port} : ${queryattempt} : "
|
|
|
|
|
- fn_print_ok_eol_nl
|
|
|
|
|
- fn_script_log_pass "Querying port: ${ip}:${port} : ${queryattempt} : OK"
|
|
|
|
|
- exitcode=0
|
|
|
|
|
- break
|
|
|
|
|
- else
|
|
|
|
|
- # Server failed query
|
|
|
|
|
- fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}"
|
|
|
|
|
|
|
+ if [ "${queryattempt}" == "5" ]; then
|
|
|
|
|
+ # Server failed query 4 times confirmed failure
|
|
|
|
|
+ fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : "
|
|
|
|
|
+ fn_print_fail_eol_nl
|
|
|
|
|
+ fn_script_log_error "Querying port: ${ip}:${port} : ${queryattempt} : FAIL"
|
|
|
|
|
+ sleep 1
|
|
|
|
|
|
|
|
- if [ "${queryattempt}" == "5" ]; then
|
|
|
|
|
- # Server failed query 4 times confirmed failure
|
|
|
|
|
- fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : "
|
|
|
|
|
- fn_print_fail_eol_nl
|
|
|
|
|
- fn_script_log_error "Querying port: ${ip}:${port} : ${queryattempt} : FAIL"
|
|
|
|
|
- sleep 1
|
|
|
|
|
|
|
+ # Send alert if enabled
|
|
|
|
|
+ alert="restartquery"
|
|
|
|
|
+ alert.sh
|
|
|
|
|
+ command_restart.sh
|
|
|
|
|
+ break
|
|
|
|
|
+ fi
|
|
|
|
|
|
|
|
- # Send alert if enabled
|
|
|
|
|
- alert="restartquery"
|
|
|
|
|
- alert.sh
|
|
|
|
|
- command_restart.sh
|
|
|
|
|
|
|
+ # Seconds counter
|
|
|
|
|
+ for seconds in {1..15}; do
|
|
|
|
|
+ fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : ${red}${gsquerycmd}${default}"
|
|
|
|
|
+ totalseconds=$((totalseconds + 1))
|
|
|
|
|
+ sleep 1
|
|
|
|
|
+ if [ "${seconds}" == "15" ]; then
|
|
|
break
|
|
break
|
|
|
fi
|
|
fi
|
|
|
-
|
|
|
|
|
- # Seconds counter
|
|
|
|
|
- for seconds in {1..15}; do
|
|
|
|
|
- fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : ${red}${gsquerycmd}${default}"
|
|
|
|
|
- totalseconds=$((totalseconds + 1))
|
|
|
|
|
- sleep 1
|
|
|
|
|
- if [ "${seconds}" == "15" ]; then
|
|
|
|
|
- break
|
|
|
|
|
- fi
|
|
|
|
|
- done
|
|
|
|
|
- fi
|
|
|
|
|
- done
|
|
|
|
|
-fi
|
|
|
|
|
|
|
+ done
|
|
|
|
|
+ fi
|
|
|
|
|
+done
|
|
|
core_exit.sh
|
|
core_exit.sh
|