|
|
@ -16,17 +16,15 @@ fn_monitor_check_lockfile(){ |
|
|
|
fn_print_dots "Checking lockfile: " |
|
|
|
fn_print_checking_eol |
|
|
|
fn_script_log_info "Checking lockfile: CHECKING" |
|
|
|
fn_sleep_time |
|
|
|
fn_print_error "Checking lockfile: No lockfile found: " |
|
|
|
fn_print_error_eol_nl |
|
|
|
fn_script_log_error "Checking lockfile: No lockfile found: ERROR" |
|
|
|
fn_sleep_time |
|
|
|
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 |
|
|
|
if [ -f "${lockdir}/${selfname}.lock" ]&&[[ "$(cat "${lockdir}/${selfname}.lock")" =~ [A-Za-z] ]]; then |
|
|
|
date '+%s' > "${lockdir}/${selfname}.lock" |
|
|
|
fi |
|
|
|
} |
|
|
@ -37,11 +35,9 @@ fn_monitor_check_update(){ |
|
|
|
fn_print_dots "Checking active updates: " |
|
|
|
fn_print_checking_eol |
|
|
|
fn_script_log_info "Checking active updates: CHECKING" |
|
|
|
fn_sleep_time |
|
|
|
fn_print_error_nl "Checking active updates: SteamCMD is currently checking for updates: " |
|
|
|
fn_print_error_eol |
|
|
|
fn_script_log_error "Checking active updates: SteamCMD is currently checking for updates: ERROR" |
|
|
|
fn_sleep_time |
|
|
|
core_exit.sh |
|
|
|
fi |
|
|
|
} |
|
|
@ -50,18 +46,15 @@ fn_monitor_check_session(){ |
|
|
|
fn_print_dots "Checking session: " |
|
|
|
fn_print_checking_eol |
|
|
|
fn_script_log_info "Checking session: CHECKING" |
|
|
|
fn_sleep_time |
|
|
|
# uses status var from check_status.sh |
|
|
|
if [ "${status}" != "0" ]; then |
|
|
|
fn_print_ok "Checking session: " |
|
|
|
fn_print_ok_eol_nl |
|
|
|
fn_script_log_pass "Checking session: OK" |
|
|
|
fn_sleep_time |
|
|
|
else |
|
|
|
fn_print_error "Checking session: " |
|
|
|
fn_print_fail_eol_nl |
|
|
|
fn_script_log_fatal "Checking session: FAIL" |
|
|
|
fn_sleep_time |
|
|
|
alert="restart" |
|
|
|
alert.sh |
|
|
|
fn_script_log_info "Checking session: Monitor is restarting ${selfname}" |
|
|
@ -76,7 +69,6 @@ fn_monitor_check_queryport(){ |
|
|
|
fn_print_dots "Checking port: " |
|
|
|
fn_print_checking_eol |
|
|
|
fn_script_log_info "Checking port: CHECKING" |
|
|
|
fn_sleep_time |
|
|
|
if [ -n "${rconenabled}" ]&&[ "${rconenabled}" != "true" ]&&[ ${shortname} == "av" ]; then |
|
|
|
fn_print_warn "Checking port: Unable to query as rconport, rcon not enabled: " |
|
|
|
fn_print_warn_eol_nl |
|
|
@ -86,7 +78,6 @@ fn_monitor_check_queryport(){ |
|
|
|
fn_print_error_eol_nl |
|
|
|
fn_script_log_error "Checking port: Unable to query as queryport is not set: ERROR" |
|
|
|
fi |
|
|
|
fn_sleep_time |
|
|
|
core_exit.sh |
|
|
|
fi |
|
|
|
} |
|
|
@ -112,14 +103,14 @@ for queryattempt in {1..5}; do |
|
|
|
fn_print_dots "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
|
fn_print_querying_eol |
|
|
|
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 |
|
|
|
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" |
|
|
|
fn_script_log_info "Query bypassed: ${gameservername} started less than ${querydelay} minutes ago" |
|
|
|
fn_sleep_time |
|
|
|
fn_script_log_info "Server started: $(date -d @$(cat lgsm/lock/bmdmserver.lock))" |
|
|
|
fn_script_log_info "Current time: $(date)" |
|
|
|
monitorpass=1 |
|
|
|
core_exit.sh |
|
|
|
# will use query method selected in fn_monitor_loop |
|
|
@ -139,7 +130,6 @@ for queryattempt in {1..5}; do |
|
|
|
fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
|
fn_print_ok_eol_nl |
|
|
|
fn_script_log_pass "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt}: OK" |
|
|
|
fn_sleep_time |
|
|
|
monitorpass=1 |
|
|
|
if [ "${querystatus}" == "0" ]; then |
|
|
|
# Add query data to log. |
|
|
@ -170,7 +160,6 @@ for queryattempt in {1..5}; do |
|
|
|
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
|
fn_print_fail_eol |
|
|
|
fn_script_log_warn "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt}: FAIL" |
|
|
|
fn_sleep_time |
|
|
|
# Monitor will try gamedig (if supported) for first 30s then gsquery before restarting. |
|
|
|
if [ "${querymethod}" == "gsquery" ]||[ "${querymethod}" == "tcp" ]; then |
|
|
|
# gsquery will fail if longer than 60s |
|
|
@ -179,7 +168,6 @@ for queryattempt in {1..5}; do |
|
|
|
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " |
|
|
|
fn_print_fail_eol_nl |
|
|
|
fn_script_log_warn "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt}: FAIL" |
|
|
|
fn_sleep_time |
|
|
|
# Send alert if enabled. |
|
|
|
alert="restartquery" |
|
|
|
alert.sh |
|
|
@ -195,7 +183,8 @@ for queryattempt in {1..5}; do |
|
|
|
|
|
|
|
# Second counter will wait for 15s before breaking loop. |
|
|
|
for seconds in {1..15}; do |
|
|
|
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: WAIT" |
|
|
|
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: ${cyan}WAIT${default}" |
|
|
|
sleep 0.5 |
|
|
|
totalseconds=$((totalseconds + 1)) |
|
|
|
if [ "${seconds}" == "15" ]; then |
|
|
|
break |
|
|
|