mirror of
https://github.com/GameServerManagers/LinuxGSM.git
synced 2025-01-09 04:27:35 +08:00
Feature/stats change (#4363)
* feat: update unsupprted distros and add comments to info_distro * remove tmux 1.6 code * add java and tmux version and change ram to int * tidy up ram requirements used data gathered from analytics
This commit is contained in:
parent
d7964e0516
commit
8830bad9a8
@ -349,8 +349,8 @@ fi
|
|||||||
# Will warn user if their distro is no longer supported by the vendor.
|
# Will warn user if their distro is no longer supported by the vendor.
|
||||||
if [ -n "${distrosupport}" ]; then
|
if [ -n "${distrosupport}" ]; then
|
||||||
if [ "${distrosupport}" == "unsupported" ]; then
|
if [ "${distrosupport}" == "unsupported" ]; then
|
||||||
fn_print_warning_nl "${distroname} is no longer supported by the vendor. Upgrading is recommended."
|
fn_print_warning_nl "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
|
||||||
fn_script_log_warn "${distroname} is no longer supported by the vendor. Upgrading is recommended."
|
fn_script_log_warn "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -12,42 +12,57 @@ info_distro.sh
|
|||||||
# RAM requirements in megabytes for each game or engine.
|
# RAM requirements in megabytes for each game or engine.
|
||||||
|
|
||||||
if [ "${shortname}" == "ark" ]; then
|
if [ "${shortname}" == "ark" ]; then
|
||||||
ramrequirementmb="4000"
|
ramrequirementgb="7"
|
||||||
ramrequirementgb="4"
|
|
||||||
elif [ "${shortname}" == "bt" ]; then
|
|
||||||
ramrequirementmb="1000"
|
|
||||||
ramrequirementgb="1"
|
|
||||||
elif [ "${shortname}" == "mh" ]; then
|
|
||||||
ramrequirementmb="4000"
|
|
||||||
ramrequirementgb="4"
|
|
||||||
elif [ "${shortname}" == "arma3" ]; then
|
elif [ "${shortname}" == "arma3" ]; then
|
||||||
ramrequirementmb="1000"
|
ramrequirementgb="2"
|
||||||
|
elif [ "${shortname}" == "armar" ]; then
|
||||||
|
ramrequirementgb="3"
|
||||||
|
elif [ "${shortname}" == "bt" ]; then
|
||||||
ramrequirementgb="1"
|
ramrequirementgb="1"
|
||||||
elif [ "${shortname}" == "rust" ]; then
|
elif [ "${shortname}" == "cc" ]; then
|
||||||
ramrequirementmb="4000"
|
ramrequirementgb="1"
|
||||||
|
elif [ "${shortname}" == "dayz" ]; then
|
||||||
|
ramrequirementgb="5"
|
||||||
|
elif [ "${shortname}" == "dodr" ]; then
|
||||||
|
ramrequirementgb="2"
|
||||||
|
elif [ "${shortname}" == "hw" ]; then
|
||||||
|
ramrequirementgb="3"
|
||||||
|
elif [ "${shortname}" == "mc" ]; then
|
||||||
|
ramrequirementgb="1"
|
||||||
|
elif [ "${shortname}" == "pmc" ]; then
|
||||||
|
ramrequirementgb="2"
|
||||||
|
elif [ "${shortname}" == "mh" ]; then
|
||||||
ramrequirementgb="4"
|
ramrequirementgb="4"
|
||||||
elif [ "${shortname}" == "mc" ] || [ "${shortname}" == "pmc" ] || [ "${shortname}" == "wmc" ]; then
|
elif [ "${shortname}" == "ns2" ] || [ "${shortname}" == "ns2c" ]; then
|
||||||
ramrequirementmb="1000"
|
|
||||||
ramrequirementgb="1"
|
ramrequirementgb="1"
|
||||||
elif [ "${shortname}" == "ps" ]; then
|
elif [ "${shortname}" == "ps" ]; then
|
||||||
ramrequirementmb="2000"
|
|
||||||
ramrequirementgb="2"
|
ramrequirementgb="2"
|
||||||
elif [ "${shortname}" == "ns2" ] || [ "${shortname}" == "ns2c" ]; then
|
|
||||||
ramrequirementmb="1000"
|
|
||||||
ramrequirementgb="1"
|
|
||||||
elif [ "${shortname}" == "st" ]; then
|
|
||||||
ramrequirementmb="1000"
|
|
||||||
ramrequirementgb="1"
|
|
||||||
elif [ "${shortname}" == "pvr" ]; then
|
elif [ "${shortname}" == "pvr" ]; then
|
||||||
ramrequirementmb="2000"
|
ramrequirementgb="1"
|
||||||
|
elif [ "${shortname}" == "pz" ]; then
|
||||||
|
ramrequirementgb="3"
|
||||||
|
elif [ "${shortname}" == "rust" ]; then
|
||||||
|
ramrequirementgb="9"
|
||||||
|
elif [ "${shortname}" == "sdtd" ]; then
|
||||||
|
ramrequirementgb="4"
|
||||||
|
elif [ "${shortname}" == "squad" ]; then
|
||||||
ramrequirementgb="2"
|
ramrequirementgb="2"
|
||||||
|
elif [ "${shortname}" == "st" ]; then
|
||||||
|
ramrequirementgb="1"
|
||||||
|
elif [ "${shortname}" == "stn" ]; then
|
||||||
|
ramrequirementgb="3"
|
||||||
|
elif [ "${shortname}" == "tu" ]; then
|
||||||
|
ramrequirementgb="2"
|
||||||
|
elif [ "${shortname}" == "vh" ]; then
|
||||||
|
ramrequirementgb="2"
|
||||||
|
else
|
||||||
|
ramrequirementgb="0.5"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the game or engine has a minimum RAM Requirement, compare it to system's available RAM.
|
# If the game or engine has a minimum RAM Requirement, compare it to system's available RAM.
|
||||||
if [ "${ramrequirementmb}" ]; then
|
if [ "${ramrequirementgb}" ]; then
|
||||||
if [ "${physmemtotalmb}" -lt "${ramrequirementmb}" ]; then
|
if [ "${physmemtotalgb}" -lt "${ramrequirementgb}" ]; then
|
||||||
fn_print_dots "Checking RAM"
|
fn_print_dots "Checking RAM"
|
||||||
# Warn the user.
|
|
||||||
fn_print_warn_nl "Checking RAM: ${ramrequirementgb}G required, ${physmemtotal} available"
|
fn_print_warn_nl "Checking RAM: ${ramrequirementgb}G required, ${physmemtotal} available"
|
||||||
echo "* ${gamename} server may fail to run or experience poor performance."
|
echo "* ${gamename} server may fail to run or experience poor performance."
|
||||||
fn_sleep_time_5
|
fn_sleep_time_5
|
||||||
|
@ -34,7 +34,7 @@ fn_print_header
|
|||||||
echo -e "${lightblue}Architecture:\t\t${default}${arch}"
|
echo -e "${lightblue}Architecture:\t\t${default}${arch}"
|
||||||
echo -e "${lightblue}Kernel:\t\t${default}${kernel}"
|
echo -e "${lightblue}Kernel:\t\t${default}${kernel}"
|
||||||
echo -e "${lightblue}Hostname:\t\t${default}${HOSTNAME}"
|
echo -e "${lightblue}Hostname:\t\t${default}${HOSTNAME}"
|
||||||
echo -e "${lightblue}tmux:\t\t${default}${tmuxv}"
|
echo -e "${lightblue}tmux:\t\t${default}${tmuxversion}"
|
||||||
echo -e "${lightblue}Avg Load:\t\t${default}${load}"
|
echo -e "${lightblue}Avg Load:\t\t${default}${load}"
|
||||||
echo -e "${lightblue}Free Memory:\t\t${default}${physmemfree}"
|
echo -e "${lightblue}Free Memory:\t\t${default}${physmemfree}"
|
||||||
echo -e "${lightblue}Free Disk:\t\t${default}${availspace}"
|
echo -e "${lightblue}Free Disk:\t\t${default}${availspace}"
|
||||||
|
@ -73,47 +73,23 @@ fn_start_tmux() {
|
|||||||
touch "${consolelog}"
|
touch "${consolelog}"
|
||||||
|
|
||||||
# tmux compiled from source will return "master", therefore ignore it.
|
# tmux compiled from source will return "master", therefore ignore it.
|
||||||
if [ "${tmuxv}" == "master" ]; then
|
if [ "${tmuxversion}" == "master" ]; then
|
||||||
fn_script_log "tmux version: master (user compiled)"
|
fn_script_log "tmux version: master (user compiled)"
|
||||||
echo -e "tmux version: master (user compiled)" >> "${consolelog}"
|
echo -e "tmux version: master (user compiled)" >> "${consolelog}"
|
||||||
if [ "${consolelogging}" == "on" ] || [ -z "${consolelogging}" ]; then
|
fi
|
||||||
if [ "${logtimestamp}" == "on" ]; then
|
|
||||||
tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $addtimestamp\" >> '${consolelog}'"
|
|
||||||
else
|
|
||||||
tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [ -n "${tmuxv}" ]; then
|
# Enable console logging.
|
||||||
# tmux pipe-pane not supported in tmux versions < 1.6.
|
if [ "${consolelogging}" == "on" ] || [ -z "${consolelogging}" ]; then
|
||||||
if [ "${tmuxvdigit}" -lt "16" ]; then
|
if [ "${logtimestamp}" == "on" ]; then
|
||||||
echo -e "Console logging disabled: tmux => 1.6 required
|
tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $addtimestamp\" >> '${consolelog}'"
|
||||||
https://linuxgsm.com/tmux-upgrade
|
else
|
||||||
Currently installed: $(tmux -V)" > "${consolelog}"
|
tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'"
|
||||||
|
|
||||||
# Console logging disabled: Bug in tmux 1.8 breaks logging.
|
|
||||||
elif [ "${tmuxvdigit}" -eq "18" ]; then
|
|
||||||
echo -e "Console logging disabled: Bug in tmux 1.8 breaks logging
|
|
||||||
https://linuxgsm.com/tmux-upgrade
|
|
||||||
Currently installed: $(tmux -V)" > "${consolelog}"
|
|
||||||
# Console logging enable or not set.
|
|
||||||
elif [ "${consolelogging}" == "on" ] || [ -z "${consolelogging}" ]; then
|
|
||||||
if [ "${logtimestamp}" == "on" ]; then
|
|
||||||
tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $addtimestamp\" >> '${consolelog}'"
|
|
||||||
else
|
|
||||||
tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "Unable to detect tmux version" >> "${consolelog}"
|
echo -e "Console logging disabled in settings" >> "${consolelog}"
|
||||||
fn_script_log_warn "Unable to detect tmux version"
|
fn_script_log_info "Console logging disabled in settings"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Console logging disabled.
|
|
||||||
if [ "${consolelogging}" == "off" ]; then
|
|
||||||
echo -e "Console logging disabled in settings" >> "${consolelog}"
|
|
||||||
fn_script_log_info "Console logging disabled by user"
|
|
||||||
fi
|
|
||||||
fn_sleep_time_1
|
fn_sleep_time_1
|
||||||
|
|
||||||
# If the server fails to start.
|
# If the server fails to start.
|
||||||
@ -123,7 +99,7 @@ fn_start_tmux() {
|
|||||||
fn_script_log_fail "Unable to start ${servername}"
|
fn_script_log_fail "Unable to start ${servername}"
|
||||||
if [ -s "${lgsmlogdir}/.${selfname}-tmux-error.tmp" ]; then
|
if [ -s "${lgsmlogdir}/.${selfname}-tmux-error.tmp" ]; then
|
||||||
fn_print_fail_nl "Unable to start ${servername}: tmux error:"
|
fn_print_fail_nl "Unable to start ${servername}: tmux error:"
|
||||||
fn_script_log_fail "Unable to start ${servername}: tmux error:"
|
fn_script_log_fail "Unable to start ${servername}: tmux error"
|
||||||
echo -e ""
|
echo -e ""
|
||||||
echo -e "Command"
|
echo -e "Command"
|
||||||
fn_messages_separator
|
fn_messages_separator
|
||||||
|
@ -21,114 +21,107 @@ fi
|
|||||||
|
|
||||||
## Distro
|
## Distro
|
||||||
# Returns architecture, kernel and distro/os.
|
# Returns architecture, kernel and distro/os.
|
||||||
arch="$(uname -m)"
|
arch="$(uname -m)" # Architecture e.g. x86_64
|
||||||
kernel="$(uname -r)"
|
kernel="$(uname -r)" # Kernel e.g. 2.6.32-042stab120.16
|
||||||
|
|
||||||
# Distro Name - Ubuntu 16.04 LTS
|
|
||||||
# Distro Version - 16.04
|
|
||||||
# Distro ID - ubuntu
|
|
||||||
# Distro Codename - xenial
|
|
||||||
|
|
||||||
# Gathers distro info from various sources filling in missing gaps.
|
# Gathers distro info from various sources filling in missing gaps.
|
||||||
distro_info_array=(os-release lsb_release hostnamectl debian_version redhat-release)
|
distro_info_array=(os-release lsb_release hostnamectl debian_version redhat-release)
|
||||||
for distro_info in "${distro_info_array[@]}"; do
|
for distro_info in "${distro_info_array[@]}"; do
|
||||||
if [ -f "/etc/os-release" ] && [ "${distro_info}" == "os-release" ]; then
|
if [ -f "/etc/os-release" ] && [ "${distro_info}" == "os-release" ]; then
|
||||||
distroname="$(grep "PRETTY_NAME" /etc/os-release | awk -F\= '{gsub(/"/,"",$2);print $2}')"
|
distroname="$(grep "PRETTY_NAME" /etc/os-release | awk -F\= '{gsub(/"/,"",$2);print $2}')" # e.g. Ubuntu 22.04.3 LTS
|
||||||
distroversion="$(grep "VERSION_ID" /etc/os-release | awk -F\= '{gsub(/"/,"",$2);print $2}')"
|
distroversion="$(grep "VERSION_ID" /etc/os-release | awk -F\= '{gsub(/"/,"",$2);print $2}')" # e.g. 22.04
|
||||||
# Special var for rhel like distros to removed point in number e.g 8.4 to just 8.
|
# Special var for rhel like distros to remove point in number e.g 8.4 to just 8.
|
||||||
distroversionrh="$(sed -nr 's/^VERSION_ID="([0-9]*).+?"/\1/p' /etc/os-release)"
|
if [[ "${distroidlike}" == *"rhel"* ]] || [ "${distroid}" == "rhel" ]; then
|
||||||
distroid="$(grep "ID=" /etc/os-release | grep -v _ID | awk -F\= '{gsub(/"/,"",$2);print $2}')"
|
distroversionrh="$(sed -nr 's/^VERSION_ID="([0-9]*).+?"/\1/p' /etc/os-release)" # e.g. 8
|
||||||
distroidlike="$(grep "ID_LIKE=" /etc/os-release | grep -v _ID | awk -F\= '{gsub(/"/,"",$2);print $2}')"
|
fi
|
||||||
distrocodename="$(grep "VERSION_CODENAME" /etc/os-release | awk -F\= '{gsub(/"/,"",$2);print $2}')"
|
distroid="$(grep "ID=" /etc/os-release | grep -v _ID | awk -F\= '{gsub(/"/,"",$2);print $2}')" # e.g. ubuntu
|
||||||
|
distroidlike="$(grep "ID_LIKE=" /etc/os-release | grep -v _ID | awk -F\= '{gsub(/"/,"",$2);print $2}')" # e.g. debian
|
||||||
|
distrocodename="$(grep "VERSION_CODENAME" /etc/os-release | awk -F\= '{gsub(/"/,"",$2);print $2}')" # e.g. jammy
|
||||||
elif [ "$(command -v lsb_release 2> /dev/null)" ] && [ "${distro_info}" == "lsb_release" ]; then
|
elif [ "$(command -v lsb_release 2> /dev/null)" ] && [ "${distro_info}" == "lsb_release" ]; then
|
||||||
if [ -z "${distroname}" ]; then
|
if [ -z "${distroname}" ]; then
|
||||||
distroname="$(lsb_release -sd)"
|
distroname="$(lsb_release -sd)" # e.g. Ubuntu 22.04.3 LTS
|
||||||
elif [ -z "${distroversion}" ]; then
|
elif [ -z "${distroversion}" ]; then
|
||||||
distroversion="$(lsb_release -sr)"
|
distroversion="$(lsb_release -sr)" # e.g. 22.04
|
||||||
elif [ -z "${distroid}" ]; then
|
elif [ -z "${distroid}" ]; then
|
||||||
distroid="$(lsb_release -si)"
|
distroid="$(lsb_release -si)" # e.g. Ubuntu
|
||||||
elif [ -z "${distrocodename}" ]; then
|
elif [ -z "${distrocodename}" ]; then
|
||||||
distrocodename="$(lsb_release -sc)"
|
distrocodename="$(lsb_release -sc)" # e.g. jammy
|
||||||
fi
|
fi
|
||||||
elif [ "$(command -v hostnamectl 2> /dev/null)" ] && [ "${distro_info}" == "hostnamectl" ]; then
|
elif [ "$(command -v hostnamectl 2> /dev/null)" ] && [ "${distro_info}" == "hostnamectl" ]; then
|
||||||
if [ -z "${distroname}" ]; then
|
if [ -z "${distroname}" ]; then
|
||||||
distroname="$(hostnamectl | grep "Operating System" | sed 's/Operating System: //g')"
|
distroname="$(hostnamectl | grep "Operating System" | sed 's/Operating System: //g')" # e.g. Ubuntu 22.04.3 LTS
|
||||||
fi
|
fi
|
||||||
elif [ -f "/etc/debian_version" ] && [ "${distro_info}" == "debian_version" ]; then
|
elif [ -f "/etc/debian_version" ] && [ "${distro_info}" == "debian_version" ]; then
|
||||||
if [ -z "${distroname}" ]; then
|
if [ -z "${distroname}" ]; then
|
||||||
distroname="Debian $(cat /etc/debian_version)"
|
distroname="Debian $(cat /etc/debian_version)" # e.g. Debian bookworm/sid
|
||||||
elif [ -z "${distroversion}" ]; then
|
elif [ -z "${distroversion}" ]; then
|
||||||
distroversion="$(cat /etc/debian_version)"
|
distroversion="$(cat /etc/debian_version)" # e.g. bookworm/sid
|
||||||
elif [ -z "${distroid}" ]; then
|
elif [ -z "${distroid}" ]; then
|
||||||
distroid="debian"
|
distroid="debian"
|
||||||
fi
|
fi
|
||||||
elif [ -f "/etc/redhat-release" ] && [ "${distro_info}" == "redhat-release" ]; then
|
elif [ -f "/etc/redhat-release" ] && [ "${distro_info}" == "redhat-release" ]; then
|
||||||
if [ -z "${distroname}" ]; then
|
if [ -z "${distroname}" ]; then
|
||||||
distroname="$(cat /etc/redhat-release)"
|
distroname="$(cat /etc/redhat-release)" # e.g. Rocky Linux release 9.2 (Blue Onyx)
|
||||||
elif [ -z "${distroversion}" ]; then
|
elif [ -z "${distroversion}" ]; then
|
||||||
distroversion="$(rpm -qa \*-release | grep -Ei "oracle|redhat|centos|fedora" | cut -d"-" -f3)"
|
distroversion="$(rpm -qa \*-release | grep -Ei "oracle|redhat|centos|fedora|rocky|alma" | cut -d"-" -f3)" # e.g. 9.2
|
||||||
elif [ -z "${distroid}" ]; then
|
elif [ -z "${distroid}" ]; then
|
||||||
distroid="$(awk '{print $1}' /etc/redhat-release)"
|
distroid="$(awk '{print $1}' /etc/redhat-release)" # e.g. Rocky
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Get virtual environment type.
|
# Get virtual environment type.
|
||||||
if [ "$(command -v systemd-detect-virt 2> /dev/null)" ]; then
|
if [ "$(command -v systemd-detect-virt 2> /dev/null)" ]; then
|
||||||
virtualenvironment="$(systemd-detect-virt)"
|
virtualenvironment="$(systemd-detect-virt)" # e.g. kvm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Some RHEL based distros use 8.4 instead of just 8.
|
# distroversioncsv is used for selecting the correct distro csv in data directory
|
||||||
if [[ "${distroidlike}" == *"rhel"* ]] || [ "${distroid}" == "rhel" ]; then
|
if [ -n "${distroversionrh}" ]; then
|
||||||
distroversioncsv="${distroversionrh}"
|
distroversioncsv="${distroversionrh}" # e.g. 8
|
||||||
else
|
else
|
||||||
distroversioncsv="${distroversion}"
|
distroversioncsv="${distroversion}" # e.g. 22.04
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if distro supported by distro vendor.
|
# Check if distro supported by distro vendor.
|
||||||
|
# distro-info available in debian based distros.
|
||||||
if [ "$(command -v distro-info 2> /dev/null)" ]; then
|
if [ "$(command -v distro-info 2> /dev/null)" ]; then
|
||||||
distrosunsupported="$(distro-info --unsupported)"
|
distrosunsupported="$(distro-info --unsupported)"
|
||||||
distrosunsupported_array=("${distrosunsupported}")
|
distrosunsupported_array=("${distrosunsupported}")
|
||||||
for distrounsupported in "${distrosunsupported_array[@]}"; do
|
for distrounsupported in "${distrosunsupported_array[@]}"; do
|
||||||
if [ "${distrounsupported}" == "${distrocodename}" ]; then
|
if [ "${distrounsupported}" == "${distrocodename}" ]; then
|
||||||
distrosupport=unsupported
|
distrosupport="unsupported"
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
distrosupport=supported
|
distrosupport="supported"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
elif [[ "${distroidlike}" == *"rhel"* ]] || [ "${distroid}" == "rhel" ]; then
|
||||||
distrosupport=unknown
|
# RHEL/CentOS 7 EOL 2024-06-30. Will be unsupported after this date.
|
||||||
fi
|
if [ "${distroversionrh}" -lt "8" ] && [ "$(date +%s)" -lt "1719705600" ]; then
|
||||||
|
distrosupport="unsupported"
|
||||||
## Glibc version
|
|
||||||
# e.g: 1.17
|
|
||||||
glibcversion="$(ldd --version | sed -n '1s/.* //p')"
|
|
||||||
|
|
||||||
## tmux version
|
|
||||||
# e.g: tmux 1.6
|
|
||||||
if [ ! "$(command -V tmux 2> /dev/null)" ]; then
|
|
||||||
tmuxv="${red}NOT INSTALLED!${default}"
|
|
||||||
tmuxvdigit="0"
|
|
||||||
else
|
|
||||||
tmuxvdigit="$(tmux -V | sed "s/tmux //" | sed -n '1 p' | tr -cd '[:digit:]')"
|
|
||||||
if [ "${tmuxvdigit}" -lt "16" ]; then
|
|
||||||
tmuxv="$(tmux -V) (>= 1.6 required for console log)"
|
|
||||||
else
|
else
|
||||||
tmuxv="$(tmux -V)"
|
distrosupport="supported"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## Glibc version
|
||||||
|
glibcversion="$(ldd --version | sed -n '1s/.* //p')" # e.g: 2.17
|
||||||
|
|
||||||
|
## tmux version
|
||||||
|
if [ "$(command -V tmux 2> /dev/null)" ]; then
|
||||||
|
tmuxversion="$(tmux -V | awk '{print $2}')" # e.g: tmux 3.3
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$(command -V java 2> /dev/null)" ]; then
|
if [ "$(command -V java 2> /dev/null)" ]; then
|
||||||
javaversion="$(java -version 2>&1 | grep "version")"
|
javaversion="$(java -version 2>&1 | grep "version")" # e.g: openjdk version "17.0.8.1" 2023-08-24
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(command -v mono 2> /dev/null)" ]; then
|
if [ "$(command -v mono 2> /dev/null)" ]; then
|
||||||
monoversion="$(mono --version 2>&1 | grep -Po '(?<=version )\d')"
|
monoversion="$(mono --version 2>&1 | grep -Po '(?<=version )\d')" # e.g: 6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(command -v dotnet 2> /dev/null)" ]; then
|
if [ "$(command -v dotnet 2> /dev/null)" ]; then
|
||||||
dotnetversion="$(dotnet --list-runtimes | grep -E 'Microsoft\.NETCore\.App' | awk '{print $2}')"
|
dotnetversion="$(dotnet --list-runtimes | grep -E 'Microsoft\.NETCore\.App' | awk '{print $2}')" # e.g: 6.0.0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Uptime
|
## Uptime
|
||||||
@ -141,16 +134,16 @@ days="$((uptime / 60 / 60 / 24))"
|
|||||||
### Performance information
|
### Performance information
|
||||||
|
|
||||||
## Average server load
|
## Average server load
|
||||||
load="$(uptime | awk -F 'load average: ' '{ print $2 }')"
|
load="$(uptime | awk -F 'load average: ' '{ print $2 }')" # e.g 0.01, 0.05, 0.11
|
||||||
|
|
||||||
## CPU information
|
## CPU information
|
||||||
cpumodel="$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')"
|
cpumodel="$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')" # e.g Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
|
||||||
cpucores="$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo)"
|
cpucores="$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo)"
|
||||||
cpufreqency="$(awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')"
|
cpufreqency="$(awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')" # e.g 2394.503
|
||||||
# CPU usage of the game server pid
|
# CPU usage of the game server pid
|
||||||
if [ -n "${gameserverpid}" ]; then
|
if [ -n "${gameserverpid}" ]; then
|
||||||
cpuused="$(ps --forest -o pcpu -g "${gameserverpid}" | awk '{s+=$1} END {print s}')"
|
cpuused="$(ps --forest -o pcpu -g "${gameserverpid}" | awk '{s+=$1} END {print s}')" # integer
|
||||||
cpuusedmhz="$(echo "${cpufreqency} * ${cpuused} / 100" | bc)"
|
cpuusedmhz="$(echo "${cpufreqency} * ${cpuused} / 100" | bc)" # integer
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Memory information
|
## Memory information
|
||||||
@ -161,36 +154,35 @@ if [ "$(command -v numfmt 2> /dev/null)" ]; then
|
|||||||
# Issue #2005 - Kernel 3.14+ contains MemAvailable which should be used. All others will be calculated.
|
# Issue #2005 - Kernel 3.14+ contains MemAvailable which should be used. All others will be calculated.
|
||||||
|
|
||||||
# get the raw KB values of these fields.
|
# get the raw KB values of these fields.
|
||||||
physmemtotalkb="$(grep MemTotal /proc/meminfo | awk '{print $2}')"
|
physmemtotalkb="$(grep MemTotal /proc/meminfo | awk '{print $2}')" # integer
|
||||||
physmemfreekb="$(grep ^MemFree /proc/meminfo | awk '{print $2}')"
|
physmemfreekb="$(grep ^MemFree /proc/meminfo | awk '{print $2}')" # integer
|
||||||
physmembufferskb="$(grep ^Buffers /proc/meminfo | awk '{print $2}')"
|
physmembufferskb="$(grep ^Buffers /proc/meminfo | awk '{print $2}')" # integer
|
||||||
physmemcachedkb="$(grep ^Cached /proc/meminfo | awk '{print $2}')"
|
physmemcachedkb="$(grep ^Cached /proc/meminfo | awk '{print $2}')" # integer
|
||||||
physmemreclaimablekb="$(grep ^SReclaimable /proc/meminfo | awk '{print $2}')"
|
physmemreclaimablekb="$(grep ^SReclaimable /proc/meminfo | awk '{print $2}')" # integer
|
||||||
|
|
||||||
# check if MemAvailable Exists.
|
# check if MemAvailable Exists.
|
||||||
if grep -q ^MemAvailable /proc/meminfo; then
|
if grep -q ^MemAvailable /proc/meminfo; then
|
||||||
physmemactualfreekb="$(grep ^MemAvailable /proc/meminfo | awk '{print $2}')"
|
physmemactualfreekb="$(grep ^MemAvailable /proc/meminfo | awk '{print $2}')" # integer
|
||||||
else
|
else
|
||||||
physmemactualfreekb="$((physmemfreekb + physmembufferskb + physmemcachedkb))"
|
physmemactualfreekb="$((physmemfreekb + physmembufferskb + physmemcachedkb))" # integer
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Available RAM and swap.
|
# Available RAM and swap.
|
||||||
physmemtotalmb="$((physmemtotalkb / 1024))"
|
physmemtotalmb="$(((physmemtotalkb + 512) / 1024))" # integer # integer
|
||||||
physmemtotal="$(numfmt --to=iec --from=iec --suffix=B "${physmemtotalkb}K")"
|
physmemtotalgb="$(((physmemtotalmb + 512) / 1024))" # integer # integer
|
||||||
physmemfree="$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K")"
|
physmemtotal="$(numfmt --to=iec --from=iec --suffix=B "${physmemtotalkb}K")" # string
|
||||||
physmemused="$(numfmt --to=iec --from=iec --suffix=B "$((physmemtotalkb - physmemfreekb - physmembufferskb - physmemcachedkb - physmemreclaimablekb))K")"
|
physmemfree="$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K")" # string
|
||||||
physmemavailable="$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K")"
|
physmemused="$(numfmt --to=iec --from=iec --suffix=B "$((physmemtotalkb - physmemfreekb - physmembufferskb - physmemcachedkb - physmemreclaimablekb))K")" # string
|
||||||
physmemcached="$(numfmt --to=iec --from=iec --suffix=B "$((physmemcachedkb + physmemreclaimablekb))K")"
|
physmemavailable="$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K")" # string
|
||||||
|
physmemcached="$(numfmt --to=iec --from=iec --suffix=B "$((physmemcachedkb + physmemreclaimablekb))K")" # string
|
||||||
|
|
||||||
swaptotal="$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapTotal /proc/meminfo | awk '{print $2}')K")"
|
swaptotal="$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapTotal /proc/meminfo | awk '{print $2}')K")" # string
|
||||||
swapfree="$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapFree /proc/meminfo | awk '{print $2}')K")"
|
swapfree="$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapFree /proc/meminfo | awk '{print $2}')K")" # string
|
||||||
swapused="$(numfmt --to=iec --from=iec --suffix=B "$(($(grep ^SwapTotal /proc/meminfo | awk '{print $2}') - $(grep ^SwapFree /proc/meminfo | awk '{print $2}')))K")"
|
swapused="$(numfmt --to=iec --from=iec --suffix=B "$(($(grep ^SwapTotal /proc/meminfo | awk '{print $2}') - $(grep ^SwapFree /proc/meminfo | awk '{print $2}')))K")" # string
|
||||||
# RAM usage of the game server pid
|
# RAM usage of the game server pid
|
||||||
# MB
|
|
||||||
if [ "${gameserverpid}" ]; then
|
if [ "${gameserverpid}" ]; then
|
||||||
memused="$(ps --forest -o rss -g "${gameserverpid}" | awk '{s+=$1} END {print s}' | awk '{$1/=1024;printf "%.0f",$1}{print $2}')"
|
memusedmb="$(ps --forest -o rss -g "${gameserverpid}" | awk '{s+=$1} END {print s}' | awk '{$1/=1024;printf "%.0f",$1}{print $2}')" # integer
|
||||||
# %
|
memusedpct="$(ps --forest -o %mem -g "${gameserverpid}" | awk '{s+=$1} END {print s}')" # integer
|
||||||
pmemused="$(ps --forest -o %mem -g "${gameserverpid}" | awk '{s+=$1} END {print s}')"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Older distros will need to use free.
|
# Older distros will need to use free.
|
||||||
@ -203,32 +195,32 @@ else
|
|||||||
else
|
else
|
||||||
humanreadable="-h"
|
humanreadable="-h"
|
||||||
fi
|
fi
|
||||||
physmemtotalmb="$(free -m | awk '/Mem:/ {print $2}')"
|
physmemtotalmb="$(free -m | awk '/Mem:/ {print $2}')" # string
|
||||||
physmemtotal="$(free ${humanreadable} | awk '/Mem:/ {print $2}')"
|
physmemtotal="$(free ${humanreadable} | awk '/Mem:/ {print $2}')" # string
|
||||||
physmemfree="$(free ${humanreadable} | awk '/Mem:/ {print $4}')"
|
physmemfree="$(free ${humanreadable} | awk '/Mem:/ {print $4}')" # string
|
||||||
physmemused="$(free ${humanreadable} | awk '/Mem:/ {print $3}')"
|
physmemused="$(free ${humanreadable} | awk '/Mem:/ {print $3}')" # string
|
||||||
|
|
||||||
oldfree="$(free ${humanreadable} | awk '/cache:/')"
|
oldfree="$(free ${humanreadable} | awk '/cache:/')"
|
||||||
if [ "${oldfree}" ]; then
|
if [ "${oldfree}" ]; then
|
||||||
physmemavailable="n/a"
|
physmemavailable="n/a"
|
||||||
physmemcached="n/a"
|
physmemcached="n/a"
|
||||||
else
|
else
|
||||||
physmemavailable="$(free ${humanreadable} | awk '/Mem:/ {print $7}')"
|
physmemavailable="$(free ${humanreadable} | awk '/Mem:/ {print $7}')" # string
|
||||||
physmemcached="$(free ${humanreadable} | awk '/Mem:/ {print $6}')"
|
physmemcached="$(free ${humanreadable} | awk '/Mem:/ {print $6}')" # string
|
||||||
fi
|
fi
|
||||||
|
|
||||||
swaptotal="$(free ${humanreadable} | awk '/Swap:/ {print $2}')"
|
swaptotal="$(free ${humanreadable} | awk '/Swap:/ {print $2}')" # string
|
||||||
swapused="$(free ${humanreadable} | awk '/Swap:/ {print $3}')"
|
swapused="$(free ${humanreadable} | awk '/Swap:/ {print $3}')" # string
|
||||||
swapfree="$(free ${humanreadable} | awk '/Swap:/ {print $4}')"
|
swapfree="$(free ${humanreadable} | awk '/Swap:/ {print $4}')" # string
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Disk information
|
### Disk information
|
||||||
|
|
||||||
## Available disk space on the partition.
|
## Available disk space on the partition.
|
||||||
filesystem="$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $1}')"
|
filesystem="$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $1}')" # string e.g /dev/sda
|
||||||
totalspace="$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $2}')"
|
totalspace="$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $2}')" # string e.g 20G
|
||||||
usedspace="$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $3}')"
|
usedspace="$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $3}')" # string e.g 15G
|
||||||
availspace="$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $4}')"
|
availspace="$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $4}')" # string e.g 5G
|
||||||
|
|
||||||
## LinuxGSM used space total.
|
## LinuxGSM used space total.
|
||||||
rootdirdu="$(du -sh "${rootdir}" 2> /dev/null | awk '{print $1}')"
|
rootdirdu="$(du -sh "${rootdir}" 2> /dev/null | awk '{print $1}')"
|
||||||
@ -263,21 +255,21 @@ if [ -d "${backupdir}" ]; then
|
|||||||
# If there are backups in backup dir.
|
# If there are backups in backup dir.
|
||||||
if [ "$(find "${backupdir}" -name "*.tar.gz" | wc -l)" -ne "0" ]; then
|
if [ "$(find "${backupdir}" -name "*.tar.gz" | wc -l)" -ne "0" ]; then
|
||||||
# number of backups.
|
# number of backups.
|
||||||
backupcount="$(find "${backupdir}"/*.tar.gz | wc -l)"
|
backupcount="$(find "${backupdir}"/*.tar.gz | wc -l)" # integer
|
||||||
# most recent backup.
|
# most recent backup.
|
||||||
lastbackup="$(ls -1t "${backupdir}"/*.tar.gz | head -1)"
|
lastbackup="$(ls -1t "${backupdir}"/*.tar.gz | head -1)" # string
|
||||||
# date of most recent backup.
|
# date of most recent backup.
|
||||||
lastbackupdate="$(date -r "${lastbackup}")"
|
lastbackupdate="$(date -r "${lastbackup}")" # string
|
||||||
# no of days since last backup.
|
# no of days since last backup.
|
||||||
lastbackupdaysago="$((($(date +'%s') - $(date -r "${lastbackup}" +'%s')) / 60 / 60 / 24))"
|
lastbackupdaysago="$((($(date +'%s') - $(date -r "${lastbackup}" +'%s')) / 60 / 60 / 24))" # integer
|
||||||
# size of most recent backup.
|
# size of most recent backup.
|
||||||
lastbackupsize="$(du -h "${lastbackup}" | awk '{print $1}')"
|
lastbackupsize="$(du -h "${lastbackup}" | awk '{print $1}')" # string
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Network Interface name
|
# Network Interface name
|
||||||
netint=$(${ipcommand} -o addr | grep "${ip}" | awk '{print $2}')
|
netint=$(${ipcommand} -o addr | grep "${ip}" | awk '{print $2}') # e.g eth0
|
||||||
netlink=$(${ethtoolcommand} "${netint}" 2> /dev/null | grep Speed | awk '{print $2}')
|
netlink=$(${ethtoolcommand} "${netint}" 2> /dev/null | grep Speed | awk '{print $2}') # e.g 1000Mb/s
|
||||||
|
|
||||||
# Sets the SteamCMD glibc requirement if the game server requirement is less or not required.
|
# Sets the SteamCMD glibc requirement if the game server requirement is less or not required.
|
||||||
if [ "${appid}" ]; then
|
if [ "${appid}" ]; then
|
||||||
@ -286,5 +278,5 @@ if [ "${appid}" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Gather Port Info using ss
|
# Gather Port Info using ss.
|
||||||
ssinfo="$(ss -tuplwn)"
|
ssinfo="$(ss -tuplwn)"
|
||||||
|
@ -95,7 +95,7 @@ fn_info_messages_distro() {
|
|||||||
echo -e "${lightblue}Hostname:\t${default}${HOSTNAME}"
|
echo -e "${lightblue}Hostname:\t${default}${HOSTNAME}"
|
||||||
echo -e "${lightblue}Environment:\t${default}${virtualenvironment}"
|
echo -e "${lightblue}Environment:\t${default}${virtualenvironment}"
|
||||||
echo -e "${lightblue}Uptime:\t${default}${days}d, ${hours}h, ${minutes}m"
|
echo -e "${lightblue}Uptime:\t${default}${days}d, ${hours}h, ${minutes}m"
|
||||||
echo -e "${lightblue}tmux:\t${default}${tmuxv}"
|
echo -e "${lightblue}tmux:\t${default}${tmuxversion}"
|
||||||
echo -e "${lightblue}glibc:\t${default}${glibcversion}"
|
echo -e "${lightblue}glibc:\t${default}${glibcversion}"
|
||||||
if [ -n "${javaram}" ]; then
|
if [ -n "${javaram}" ]; then
|
||||||
echo -e "${lightblue}Java:\t${default}${javaversion}"
|
echo -e "${lightblue}Java:\t${default}${javaversion}"
|
||||||
@ -191,10 +191,10 @@ fn_info_messages_gameserver_resource() {
|
|||||||
else
|
else
|
||||||
echo -e "${lightblue}CPU Used:\t${red}unknown${default}"
|
echo -e "${lightblue}CPU Used:\t${red}unknown${default}"
|
||||||
fi
|
fi
|
||||||
if [ -n "${memused}" ]; then
|
if [ -n "${memusedmb}" ]; then
|
||||||
echo -e "${lightblue}Mem Used:\t${default}${pmemused}%\t${memused}MB${default}"
|
echo -e "${lightblue}Mem Used:\t${default}${memusedpct}%\t${memusedmb}MB${default}"
|
||||||
else
|
else
|
||||||
echo -e "${lightblue}Mem Used:\t${default}${pmemused}\t${red}unknown${default}"
|
echo -e "${lightblue}Mem Used:\t${default}${memusedpct}\t${red}unknown${default}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${lightblue}CPU Used:\t${default}0%${default}"
|
echo -e "${lightblue}CPU Used:\t${default}0%${default}"
|
||||||
|
@ -54,7 +54,10 @@ uuidhardware=$(cat "/etc/machine-id")
|
|||||||
# nearest 100Mhz.
|
# nearest 100Mhz.
|
||||||
cpuusedmhzroundup="$(((cpuusedmhz + 99) / 100 * 100))"
|
cpuusedmhzroundup="$(((cpuusedmhz + 99) / 100 * 100))"
|
||||||
# nearest 100MB
|
# nearest 100MB
|
||||||
memusedroundup="$(((memused + 99) / 100 * 100))"
|
memusedmbroundup="$(((memusedmb + 99) / 100 * 100))"
|
||||||
|
|
||||||
|
# Convert any commas to dots.
|
||||||
|
physmemtotal="${physmemtotal//,/.}"
|
||||||
|
|
||||||
apisecret="A-OzP02TSMWt4_vHi6ZpUw"
|
apisecret="A-OzP02TSMWt4_vHi6ZpUw"
|
||||||
measurementid="G-0CR8V7EMT5"
|
measurementid="G-0CR8V7EMT5"
|
||||||
@ -66,22 +69,25 @@ payload="{
|
|||||||
{
|
{
|
||||||
\"name\": \"LinuxGSM\",
|
\"name\": \"LinuxGSM\",
|
||||||
\"params\": {
|
\"params\": {
|
||||||
\"cpuusedmhzroundup\": \"${cpuusedmhzroundup}MHz\",
|
\"cpuusedmhzroundup\": \"${cpuusedmhzroundup}\",
|
||||||
\"diskused\": \"${serverfilesdu}\",
|
\"diskused\": \"${serverfilesdu}\",
|
||||||
\"distro\": \"${distroname}\",
|
\"distro\": \"${distroname}\",
|
||||||
\"game\": \"${gamename}\",
|
\"game\": \"${gamename}\",
|
||||||
\"memusedroundup\": \"${memusedroundup}MB\",
|
\"memusedmbroundup\": \"${memusedmbroundup}\",
|
||||||
\"ramused\": \"${memusedroundup}MB\",
|
\"ramused\": \"${memusedmbroundup}\",
|
||||||
\"servercpu\": \"${cpumodel} ${cpucores} cores\",
|
\"servercpu\": \"${cpumodel} ${cpucores} cores\",
|
||||||
\"servercpufreq\": \"${cpufreqency} x${cpucores}\",
|
\"servercpufreq\": \"${cpufreqency} x${cpucores}\",
|
||||||
\"serverdisk\": \"${totalspace}\",
|
\"serverdisk\": \"${totalspace}\",
|
||||||
\"serverfilesdu\": \"${serverfilesdu}\",
|
\"serverfilesdu\": \"${serverfilesdu}\",
|
||||||
\"serverram\": \"${physmemtotal}\",
|
\"serverram\": \"${physmemtotal}\",
|
||||||
|
\"serverramgb\": \"${physmemtotalgb}\",
|
||||||
\"uuidhardware\": \"${uuidhardware}\",
|
\"uuidhardware\": \"${uuidhardware}\",
|
||||||
\"uuidinstall\": \"${uuidinstall}\",
|
\"uuidinstall\": \"${uuidinstall}\",
|
||||||
\"uuidinstance\": \"${uuidinstance}\",
|
\"uuidinstance\": \"${uuidinstance}\",
|
||||||
\"version\": \"${version}\",
|
\"version\": \"${version}\",
|
||||||
\"virtualenvironment\": \"${virtualenvironment}\"
|
\"virtualenvironment\": \"${virtualenvironment}\",
|
||||||
|
\"tmuxversion\": \"${tmuxversion}\",
|
||||||
|
\"java\": \"${javaversion}\"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -156,7 +162,7 @@ fn_script_log_info "* uuid-hardware: ${uuidhardware}"
|
|||||||
fn_script_log_info "* Game Name: ${gamename}"
|
fn_script_log_info "* Game Name: ${gamename}"
|
||||||
fn_script_log_info "* Distro Name: ${distroname}"
|
fn_script_log_info "* Distro Name: ${distroname}"
|
||||||
fn_script_log_info "* Game Server CPU Used: ${cpuusedmhzroundup}MHz"
|
fn_script_log_info "* Game Server CPU Used: ${cpuusedmhzroundup}MHz"
|
||||||
fn_script_log_info "* Game Server RAM Used: ${memusedroundup}MB"
|
fn_script_log_info "* Game Server RAM Used: ${memusedmbroundup}MB"
|
||||||
fn_script_log_info "* Game Server Disk Used: ${serverfilesdu}"
|
fn_script_log_info "* Game Server Disk Used: ${serverfilesdu}"
|
||||||
fn_script_log_info "* Server CPU Model: ${cpumodel}"
|
fn_script_log_info "* Server CPU Model: ${cpumodel}"
|
||||||
fn_script_log_info "* Server CPU Frequency: ${cpufreqency}"
|
fn_script_log_info "* Server CPU Frequency: ${cpufreqency}"
|
||||||
|
Loading…
Reference in New Issue
Block a user