|
@ -85,12 +85,12 @@ fn_query_gsquery(){ |
|
|
if [ ! -f "${functionsdir}/query_gsquery.py" ]; then |
|
|
if [ ! -f "${functionsdir}/query_gsquery.py" ]; then |
|
|
fn_fetch_file_github "lgsm/functions" "query_gsquery.py" "${functionsdir}" "chmodx" "norun" "noforce" "nomd5" |
|
|
fn_fetch_file_github "lgsm/functions" "query_gsquery.py" "${functionsdir}" "chmodx" "norun" "noforce" "nomd5" |
|
|
fi |
|
|
fi |
|
|
"${functionsdir}"/query_gsquery.py -a "${ip}" -p "${queryport}" -e "${querytype}" > /dev/null 2>&1 |
|
|
"${functionsdir}"/query_gsquery.py -a "${queryip}" -p "${queryport}" -e "${querytype}" > /dev/null 2>&1 |
|
|
querystatus="$?" |
|
|
querystatus="$?" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fn_query_tcp(){ |
|
|
fn_query_tcp(){ |
|
|
bash -c 'exec 3<> /dev/tcp/'${ip}'/'${queryport}'' > /dev/null 2>&1 |
|
|
bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}'' > /dev/null 2>&1 |
|
|
querystatus="$?" |
|
|
querystatus="$?" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -99,14 +99,14 @@ fn_monitor_query(){ |
|
|
# Query will wait up to 60 seconds to confirm server is down as server can become non-responsive during map changes. |
|
|
# Query will wait up to 60 seconds to confirm server is down as server can become non-responsive during map changes. |
|
|
totalseconds=0 |
|
|
totalseconds=0 |
|
|
for queryattempt in {1..5}; do |
|
|
for queryattempt in {1..5}; do |
|
|
fn_print_dots "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_dots "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_querying_eol |
|
|
fn_print_querying_eol |
|
|
fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : QUERYING" |
|
|
fn_script_log_info "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : QUERYING" |
|
|
# querydelay |
|
|
# querydelay |
|
|
if [ "$(cat "${lockdir}/${selfname}.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then |
|
|
if [ "$(cat "${lockdir}/${selfname}.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then |
|
|
fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_ok "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_delay_eol_nl |
|
|
fn_print_delay_eol_nl |
|
|
fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : DELAY" |
|
|
fn_script_log_info "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : DELAY" |
|
|
fn_script_log_info "Query bypassed: ${gameservername} started less than ${querydelay} minutes ago" |
|
|
fn_script_log_info "Query bypassed: ${gameservername} started less than ${querydelay} minutes ago" |
|
|
fn_script_log_info "Server started: $(date -d @$(cat "${lockdir}/${selfname}.lock"))" |
|
|
fn_script_log_info "Server started: $(date -d @$(cat "${lockdir}/${selfname}.lock"))" |
|
|
fn_script_log_info "Current time: $(date)" |
|
|
fn_script_log_info "Current time: $(date)" |
|
@ -126,9 +126,9 @@ for queryattempt in {1..5}; do |
|
|
|
|
|
|
|
|
if [ "${querystatus}" == "0" ]; then |
|
|
if [ "${querystatus}" == "0" ]; then |
|
|
# Server query OK. |
|
|
# Server query OK. |
|
|
fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_ok "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_ok_eol_nl |
|
|
fn_print_ok_eol_nl |
|
|
fn_script_log_pass "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt}: OK" |
|
|
fn_script_log_pass "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt}: OK" |
|
|
monitorpass=1 |
|
|
monitorpass=1 |
|
|
if [ "${querystatus}" == "0" ]; then |
|
|
if [ "${querystatus}" == "0" ]; then |
|
|
# Add query data to log. |
|
|
# Add query data to log. |
|
@ -156,17 +156,17 @@ for queryattempt in {1..5}; do |
|
|
core_exit.sh |
|
|
core_exit.sh |
|
|
else |
|
|
else |
|
|
# Server query FAIL. |
|
|
# Server query FAIL. |
|
|
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_fail_eol |
|
|
fn_print_fail_eol |
|
|
fn_script_log_warn "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt}: FAIL" |
|
|
fn_script_log_warn "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt}: FAIL" |
|
|
# Monitor will try gamedig (if supported) for first 30s then gsquery before restarting. |
|
|
# Monitor will try gamedig (if supported) for first 30s then gsquery before restarting. |
|
|
if [ "${querymethod}" == "gsquery" ]||[ "${querymethod}" == "tcp" ]; then |
|
|
if [ "${querymethod}" == "gsquery" ]||[ "${querymethod}" == "tcp" ]; then |
|
|
# gsquery will fail if longer than 60s |
|
|
# gsquery will fail if longer than 60s |
|
|
if [ "${totalseconds}" -ge "59" ]; then |
|
|
if [ "${totalseconds}" -ge "59" ]; then |
|
|
# Monitor will FAIL if over 60s and trigger gane server reboot. |
|
|
# Monitor will FAIL if over 60s and trigger gane server reboot. |
|
|
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
fn_print_fail_eol_nl |
|
|
fn_print_fail_eol_nl |
|
|
fn_script_log_warn "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt}: FAIL" |
|
|
fn_script_log_warn "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt}: FAIL" |
|
|
# Send alert if enabled. |
|
|
# Send alert if enabled. |
|
|
alert="restartquery" |
|
|
alert="restartquery" |
|
|
alert.sh |
|
|
alert.sh |
|
@ -183,7 +183,7 @@ for queryattempt in {1..5}; do |
|
|
|
|
|
|
|
|
# Second counter will wait for 15s before breaking loop. |
|
|
# Second counter will wait for 15s before breaking loop. |
|
|
for seconds in {1..15}; do |
|
|
for seconds in {1..15}; do |
|
|
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: ${cyan}WAIT${default}" |
|
|
fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: ${cyan}WAIT${default}" |
|
|
sleep 0.5 |
|
|
sleep 0.5 |
|
|
totalseconds=$((totalseconds + 1)) |
|
|
totalseconds=$((totalseconds + 1)) |
|
|
if [ "${seconds}" == "15" ]; then |
|
|
if [ "${seconds}" == "15" ]; then |
|
|