19 changed files with 412 additions and 223 deletions
@ -0,0 +1,40 @@ |
|||||
|
#!/bin/bash |
||||
|
# command_dev_query_raw.sh function |
||||
|
# Author: Daniel Gibbs |
||||
|
# Website: https://gameservermanagers.com |
||||
|
# Description: Raw gamedig output of the server. |
||||
|
|
||||
|
echo "=================================" |
||||
|
echo "Gamedig Raw Output" |
||||
|
echo "=================================" |
||||
|
echo"" |
||||
|
if [ ! "$(command -v gamedig 2>/dev/null)" ]; then |
||||
|
fn_print_failure_nl "gamedig not installed" |
||||
|
fi |
||||
|
if [ ! "$(command -v jq >/dev/null 2>&1)" ]; then |
||||
|
fn_print_failure_nl "jq not installed" |
||||
|
fi |
||||
|
|
||||
|
|
||||
|
info_config.sh |
||||
|
info_parms.sh |
||||
|
if [ "${engine}" == "idtech3_ql" ]; then |
||||
|
local engine="quakelive" |
||||
|
elif [ "${gamename}" == "Killing Floor 2" ]; then |
||||
|
local engine="unreal4" |
||||
|
fi |
||||
|
|
||||
|
query_gamedig.sh |
||||
|
echo "gamedig --type \"${gamedigengine}\" --host \"${ip}\" --port \"${port}\"|jq" |
||||
|
echo"" |
||||
|
echo "${gamedigraw}" | jq |
||||
|
echo"" |
||||
|
echo "=================================" |
||||
|
echo "gsquery Raw Output" |
||||
|
echo "=================================" |
||||
|
echo"" |
||||
|
echo "./query_gsquery.py -a \"${ip}\" -p \"${port}\" -e \"${engine}\"" |
||||
|
if [ ! -f "${functionsdir}/query_gsquery.py" ]; then |
||||
|
fn_fetch_file_github "lgsm/functions" "query_gsquery.py" "${functionsdir}" "chmodx" "norun" "noforce" "nomd5" |
||||
|
fi |
||||
|
"${functionsdir}"/query_gsquery.py -a "${ip}" -p "${port}" -e "${engine}" |
@ -1,86 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
# LinuxGSM monitor_gsquery.sh function |
|
||||
# Author: Daniel Gibbs |
|
||||
# Website: https://linuxgsm.com |
|
||||
# Description: Uses gsquery.py to query the server port. |
|
||||
# Detects if the server has frozen with the process still running. |
|
||||
|
|
||||
local commandname="MONITOR" |
|
||||
local commandaction="Monitor" |
|
||||
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" |
|
||||
|
|
||||
# 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 |
|
||||
|
|
||||
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 |
|
||||
|
|
||||
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" |
|
||||
|
|
||||
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}" |
|
||||
|
|
||||
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 |
|
||||
|
|
||||
# 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 |
|
||||
core_exit.sh |
|
@ -0,0 +1,96 @@ |
|||||
|
#!/bin/bash |
||||
|
# query_gamedig.sh function |
||||
|
# Author: Daniel Gibbs |
||||
|
# Website: https://gameservermanagers.com |
||||
|
# Description: Querys a gameserver using node-gamedig. |
||||
|
# https://github.com/sonicsnes/node-gamedig |
||||
|
|
||||
|
#Check if gamedig and jq are installed |
||||
|
if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then |
||||
|
|
||||
|
if [ "${engine}" == "idtech3_ql" ]; then |
||||
|
local engine="quakelive" |
||||
|
elif [ "${gamename}" == "Killing Floor 2" ]; then |
||||
|
local engine="unreal4" |
||||
|
fi |
||||
|
|
||||
|
local engine_query_array=( avalanche3.0 madness quakelive realvirtuality refractor source goldsource spark starbound unity3d unreal4 ) |
||||
|
for engine_query in "${engine_query_array[@]}" |
||||
|
do |
||||
|
if [ "${engine_query}" == "${engine}" ]; then |
||||
|
gamedigengine="protocol-valve" |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
local engine_query_array=( avalanche2.0 ) |
||||
|
for engine_query in "${engine_query_array[@]}" |
||||
|
do |
||||
|
if [ "${engine_query}" == "${engine}" ]; then |
||||
|
gamedigengine="jc2mp" |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
local engine_query_array=( idtech2 iw2.0 ) |
||||
|
for engine_query in "${engine_query_array[@]}" |
||||
|
do |
||||
|
if [ "${engine_query}" == "${engine}" ]; then |
||||
|
gamedigengine="protocol-quake2" |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
local engine_query_array=( idtech3 quake iw3.0 ) |
||||
|
for engine_query in "${engine_query_array[@]}" |
||||
|
do |
||||
|
if [ "${engine_query}" == "${engine}" ]; then |
||||
|
gamedigengine="protocol-quake3" |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
local shortname_query_array=( ts3 ) |
||||
|
for shortname_query in "${shortname_query_array[@]}" |
||||
|
do |
||||
|
if [ "${shortname_query}" == "${shortname}" ]; then |
||||
|
gamedigengine="teamspeak3" |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
|
||||
|
# will bypass query if server offline |
||||
|
check_status.sh |
||||
|
if [ "${status}" != "0" ]; then |
||||
|
# checks if query is working 0 = pass |
||||
|
querystatus=$(gamedig --type "${gamedigengine}" --host "${ip}" --port "${queryport}" | jq '.error|length') |
||||
|
# raw output |
||||
|
gamedigraw=$(gamedig --type "${gamedigengine}" --host "${ip}" --port "${queryport}") |
||||
|
|
||||
|
# server name |
||||
|
gdname=$(echo "${gamedigraw}" | jq -re '.name') |
||||
|
if [ "${gdname}" == "null" ]; then |
||||
|
gdname= |
||||
|
fi |
||||
|
|
||||
|
# numplayers |
||||
|
gdplayers=$(echo "${gamedigraw}" | jq -re '.players|length') |
||||
|
if [ "${gdplayers}" == "null" ]; then |
||||
|
gdplayers= |
||||
|
fi |
||||
|
|
||||
|
# maxplayers |
||||
|
gdmaxplayers=$(echo "${gamedigraw}" | jq -re '.maxplayers|length') |
||||
|
if [ "${gdmaxplayers}" == "null" ]; then |
||||
|
maxplayers= |
||||
|
fi |
||||
|
|
||||
|
# current map |
||||
|
gdmap=$(echo "${gamedigraw}" | jq -re '.map') |
||||
|
if [ "${gdmap}" == "null" ]; then |
||||
|
gdmap= |
||||
|
fi |
||||
|
|
||||
|
# numbots |
||||
|
gdbots=$(echo "${gamedigraw}" | jq -re '.raw.numbots') |
||||
|
if [ "${gdbots}" == "null" ]; then |
||||
|
gdbots= |
||||
|
fi |
||||
|
fi |
||||
|
fi |
Loading…
Reference in new issue