From 7a38c17186e969145a2ebcdc4b270f7ec05d0e31 Mon Sep 17 00:00:00 2001 From: Jimmy Maple <38733055+jimmyatSplunk@users.noreply.github.com> Date: Thu, 16 Apr 2020 10:02:34 -0400 Subject: [PATCH] fix(bug): gamedig not using the correct JSON object (#2821) --- README.md | 1 + lgsm/functions/command_monitor.sh | 14 ++++++++------ lgsm/functions/query_gamedig.sh | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 25996581a..6fecaea1a 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! + diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 6d78e75da..f538c7073 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -12,7 +12,7 @@ local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_monitor_check_lockfile(){ # Monitor does not run it lockfile is not found. - if [ ! -f "${lockdir}/${selfname}.lock" ]; then + if [ ! -f "${rootdir}/${lockselfname}" ]; then fn_print_dots "Checking lockfile: " fn_print_checking_eol fn_script_log_info "Checking lockfile: CHECKING" @@ -21,13 +21,13 @@ fn_monitor_check_lockfile(){ fn_print_error_eol_nl fn_script_log_error "Checking lockfile: No lockfile found: ERROR" fn_sleep_time - echo -en "* Start ${selfname} to run monitor." + echo -e "* Start ${selfname} to run monitor." core_exit.sh fi # Fix if lockfile is not unix time or contains letters - if [[ "$(cat "${lockdir}/${selfname}.lock")" =~ [A-Za-z] ]]; then - date '+%s' > "${lockdir}/${selfname}.lock" + if [[ "$(cat "${rootdir}/${lockselfname}")" =~ [A-Za-z] ]]; then + date '+%s' > "${rootdir}/${lockselfname}" fi } @@ -108,7 +108,7 @@ for queryattempt in {1..5}; do fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : QUERYING" fn_sleep_time # querydelay - if [ "$(cat "${lockdir}/${selfname}.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then + if [ "$(cat "${rootdir}/${lockselfname}")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " fn_print_delay_eol_nl fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : DELAY" @@ -147,6 +147,9 @@ for queryattempt in {1..5}; do if [ "${gdplayers}" ]; then fn_script_log_info "Players: ${gdplayers}/${gdmaxplayers}" fi + if [ "${gdbots}" ]; then + fn_script_log_info "Bots: ${gdbots}" + fi if [ "${gdmap}" ]; then fn_script_log_info "Map: ${gdmap}" fi @@ -236,7 +239,6 @@ info_parms.sh # query pre-checks fn_monitor_check_lockfile -check_last_update.sh fn_monitor_check_update fn_monitor_check_session # Monitor will not continue if session only check. diff --git a/lgsm/functions/query_gamedig.sh b/lgsm/functions/query_gamedig.sh index 4f1bc5638..bfe38b937 100644 --- a/lgsm/functions/query_gamedig.sh +++ b/lgsm/functions/query_gamedig.sh @@ -30,7 +30,7 @@ if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; fi # numplayers. - gdplayers=$(echo -e "${gamedigraw}" | jq -re '.players') + gdplayers=$(echo -e "${gamedigraw}" | jq -re '.raw.vanilla.raw.players.online') if [ "${gdplayers}" == "null" ]; then unset gdplayers elif [ "${gdplayers}" == "[]" ]; then