@ -21,114 +21,107 @@ fi
## Distro
# Returns architecture, kernel and distro/os.
arch = " $( uname -m) "
kernel = " $( uname -r) "
# Distro Name - Ubuntu 16.04 LTS
# Distro Version - 16.04
# Distro ID - ubuntu
# Distro Codename - xenial
arch = " $( uname -m) " # Architecture e.g. x86_64
kernel = " $( uname -r) " # Kernel e.g. 2.6.32-042stab120.16
# Gathers distro info from various sources filling in missing gaps.
distro_info_array = ( os-release lsb_release hostnamectl debian_version redhat-release)
for distro_info in " ${ distro_info_array [@] } " ; do
if [ -f "/etc/os-release" ] && [ " ${ distro_info } " = = "os-release" ] ; then
distroname = " $( grep "PRETTY_NAME" /etc/os-release | awk -F\= '{gsub(/"/,"",$2);print $2}' ) "
distroversion = " $( grep "VERSION_ID" /etc/os-release | awk -F\= '{gsub(/"/,"",$2);print $2}' ) "
# Special var for rhel like distros to removed point in number e.g 8.4 to just 8.
distroversionrh = " $( sed -nr 's/^VERSION_ID="([0-9]*).+?"/\1/p' /etc/os-release) "
distroid = " $( grep "ID=" /etc/os-release | grep -v _ID | awk -F\= '{gsub(/"/,"",$2);print $2}' ) "
distroidlike = " $( grep "ID_LIKE=" /etc/os-release | grep -v _ID | awk -F\= '{gsub(/"/,"",$2);print $2}' ) "
distrocodename = " $( grep "VERSION_CODENAME" /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}' ) " # e.g. 22.04
# Special var for rhel like distros to remove point in number e.g 8.4 to just 8.
if [ [ " ${ distroidlike } " = = *"rhel" * ] ] || [ " ${ distroid } " = = "rhel" ] ; then
distroversionrh = " $( sed -nr 's/^VERSION_ID="([0-9]*).+?"/\1/p' /etc/os-release) " # e.g. 8
fi
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
if [ -z " ${ distroname } " ] ; then
distroname = " $( lsb_release -sd) "
distroname = " $( lsb_release -sd) " # e.g. Ubuntu 22.04.3 LTS
elif [ -z " ${ distroversion } " ] ; then
distroversion = " $( lsb_release -sr) "
distroversion = " $( lsb_release -sr) " # e.g. 22.04
elif [ -z " ${ distroid } " ] ; then
distroid = " $( lsb_release -si) "
distroid = " $( lsb_release -si) " # e.g. Ubuntu
elif [ -z " ${ distrocodename } " ] ; then
distrocodename = " $( lsb_release -sc) "
distrocodename = " $( lsb_release -sc) " # e.g. jammy
fi
elif [ " $( command -v hostnamectl 2> /dev/null) " ] && [ " ${ distro_info } " = = "hostnamectl" ] ; 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
elif [ -f "/etc/debian_version" ] && [ " ${ distro_info } " = = "debian_version" ] ; 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
distroversion = " $( cat /etc/debian_version) "
distroversion = " $( cat /etc/debian_version) " # e.g. bookworm/sid
elif [ -z " ${ distroid } " ] ; then
distroid = "debian"
fi
elif [ -f "/etc/redhat-release" ] && [ " ${ distro_info } " = = "redhat-release" ] ; 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
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
distroid = " $( awk '{print $1}' /etc/redhat-release) "
distroid = " $( awk '{print $1}' /etc/redhat-release) " # e.g. Rocky
fi
fi
done
# Get virtual environment type.
if [ " $( command -v systemd-detect-virt 2> /dev/null) " ] ; then
virtualenvironment = " $( systemd-detect-virt) "
virtualenvironment = " $( systemd-detect-virt) " # e.g. kvm
fi
# Some RHEL based distros use 8.4 instead of just 8.
if [ [ " ${ distroidlike } " = = *"rhel" * ] ] || [ " ${ distroid } " = = "rhel " ] ; then
distroversioncsv = " ${ distroversionrh } "
# distroversioncsv is used for selecting the correct distro csv in data directory
if [ -n " ${ distroversionrh } " ] ; then
distroversioncsv = " ${ distroversionrh } " # e.g. 8
else
distroversioncsv = " ${ distroversion } "
distroversioncsv = " ${ distroversion } " # e.g. 22.04
fi
# Check if distro supported by distro vendor.
# distro-info available in debian based distros.
if [ " $( command -v distro-info 2> /dev/null) " ] ; then
distrosunsupported = " $( distro-info --unsupported) "
distrosunsupported_array = ( " ${ distrosunsupported } " )
for distrounsupported in " ${ distrosunsupported_array [@] } " ; do
if [ " ${ distrounsupported } " = = " ${ distrocodename } " ] ; then
distrosupport = unsupported
distrosupport = " unsupported"
break
else
distrosupport = supported
distrosupport = " supported"
fi
done
else
distrosupport = unknown
elif [ [ " ${ distroidlike } " = = *"rhel" * ] ] || [ " ${ distroid } " = = "rhel" ] ; then
# RHEL/CentOS 7 EOL 2024-06-30. Will be unsupported after this date.
if [ " ${ distroversionrh } " -lt "8" ] && [ " $( date +%s) " -lt "1719705600" ] ; then
distrosupport = "unsupported"
else
distrosupport = "supported"
fi
fi
## Glibc version
# e.g: 1.17
glibcversion = " $( ldd --version | sed -n '1s/.* //p' ) "
glibcversion = " $( ldd --version | sed -n '1s/.* //p' ) " # e.g: 2.17
## 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
tmuxv = " $( tmux -V) "
fi
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
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
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
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
## Uptime
@ -141,16 +134,16 @@ days="$((uptime / 60 / 60 / 24))"
### Performance information
## 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
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) "
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
if [ -n " ${ gameserverpid } " ] ; then
cpuused = " $( ps --forest -o pcpu -g " ${ gameserverpid } " | awk '{s+=$1} END {print s}' ) "
cpuusedmhz = " $( echo " ${ cpufreqency } * ${ cpuused } / 100 " | bc) "
cpuused = " $( ps --forest -o pcpu -g " ${ gameserverpid } " | awk '{s+=$1} END {print s}' ) " # integer
cpuusedmhz = " $( echo " ${ cpufreqency } * ${ cpuused } / 100 " | bc) " # integer
fi
## 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.
# get the raw KB values of these fields.
physmemtotalkb = " $( grep MemTotal /proc/meminfo | awk '{print $2}' ) "
physmemfreekb = " $( grep ^MemFree /proc/meminfo | awk '{print $2}' ) "
physmembufferskb = " $( grep ^Buffers /proc/meminfo | awk '{print $2}' ) "
physmemcachedkb = " $( grep ^Cached /proc/meminfo | awk '{print $2}' ) "
physmemreclaimablekb = " $( grep ^SReclaimable /proc/meminfo | awk '{print $2}' ) "
physmemtotalkb = " $( grep MemTotal /proc/meminfo | awk '{print $2}' ) " # integer
physmemfreekb = " $( grep ^MemFree /proc/meminfo | awk '{print $2}' ) " # integer
physmembufferskb = " $( grep ^Buffers /proc/meminfo | awk '{print $2}' ) " # integer
physmemcachedkb = " $( grep ^Cached /proc/meminfo | awk '{print $2}' ) " # integer
physmemreclaimablekb = " $( grep ^SReclaimable /proc/meminfo | awk '{print $2}' ) " # integer
# check if MemAvailable Exists.
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
physmemactualfreekb = " $(( physmemfreekb + physmembufferskb + physmemcachedkb)) "
physmemactualfreekb = " $(( physmemfreekb + physmembufferskb + physmemcachedkb)) " # integer
fi
# Available RAM and swap.
physmemtotalmb = " $(( physmemtotalkb / 1024 )) "
physmemtotal = " $( numfmt --to= iec --from= iec --suffix= B " ${ physmemtotalkb } K " ) "
physmemfree = " $( numfmt --to= iec --from= iec --suffix= B " ${ physmemactualfreekb } K " ) "
physmemused = " $( numfmt --to= iec --from= iec --suffix= B " $(( physmemtotalkb - physmemfreekb - physmembufferskb - physmemcachedkb - physmemreclaimablekb)) K " ) "
physmemavailable = " $( numfmt --to= iec --from= iec --suffix= B " ${ physmemactualfreekb } K " ) "
physmemcached = " $( numfmt --to= iec --from= iec --suffix= B " $(( physmemcachedkb + physmemreclaimablekb)) K " ) "
swaptotal = " $( numfmt --to= iec --from= iec --suffix= B " $( grep ^SwapTotal /proc/meminfo | awk '{print $2}' ) K " ) "
swapfree = " $( numfmt --to= iec --from= iec --suffix= B " $( 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 " ) "
physmemtotalmb = " $(( ( physmemtotalkb + 512 ) / 1024 )) " # integer # integer
physmemtotalgb = " $(( ( physmemtotalmb + 512 ) / 1024 )) " # integer # integer
physmemtotal = " $( numfmt --to= iec --from= iec --suffix= B " ${ physmemtotalkb } K " ) " # string
physmemfree = " $( numfmt --to= iec --from= iec --suffix= B " ${ physmemactualfreekb } K " ) " # string
physmemused = " $( numfmt --to= iec --from= iec --suffix= B " $(( physmemtotalkb - physmemfreekb - physmembufferskb - physmemcachedkb - physmemreclaimablekb)) K " ) " # string
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 " ) " # string
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 " ) " # string
# RAM usage of the game server pid
# MB
if [ " ${ gameserverpid } " ] ; then
memused = " $( ps --forest -o rss -g " ${ gameserverpid } " | awk '{s+=$1} END {print s}' | awk '{$1/=1024;printf "%.0f",$1}{print $2}' ) "
# %
pmemused = " $( ps --forest -o %mem -g " ${ gameserverpid } " | awk '{s+=$1} END {print s}' ) "
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
fi
else
# Older distros will need to use free.
@ -203,32 +195,32 @@ else
else
humanreadable = "-h"
fi
physmemtotalmb = " $( free -m | awk '/Mem:/ {print $2}' ) "
physmemtotal = " $( free ${ humanreadable } | awk '/Mem:/ {print $2}' ) "
physmemfree = " $( free ${ humanreadable } | awk '/Mem:/ {print $4}' ) "
physmemused = " $( free ${ humanreadable } | awk '/Mem:/ {print $3}' ) "
physmemtotalmb = " $( free -m | awk '/Mem:/ {print $2}' ) " # string
physmemtotal = " $( free ${ humanreadable } | awk '/Mem:/ {print $2}' ) " # string
physmemfree = " $( free ${ humanreadable } | awk '/Mem:/ {print $4}' ) " # string
physmemused = " $( free ${ humanreadable } | awk '/Mem:/ {print $3}' ) " # string
oldfree = " $( free ${ humanreadable } | awk '/cache:/' ) "
if [ " ${ oldfree } " ] ; then
physmemavailable = "n/a"
physmemcached = "n/a"
else
physmemavailable = " $( free ${ humanreadable } | awk '/Mem:/ {print $7}' ) "
physmemcached = " $( free ${ humanreadable } | awk '/Mem:/ {print $6}' ) "
physmemavailable = " $( free ${ humanreadable } | awk '/Mem:/ {print $7}' ) " # string
physmemcached = " $( free ${ humanreadable } | awk '/Mem:/ {print $6}' ) " # string
fi
swaptotal = " $( free ${ humanreadable } | awk '/Swap:/ {print $2}' ) "
swapused = " $( free ${ humanreadable } | awk '/Swap:/ {print $3}' ) "
swapfree = " $( free ${ humanreadable } | awk '/Swap:/ {print $4}' ) "
swaptotal = " $( free ${ humanreadable } | awk '/Swap:/ {print $2}' ) " # string
swapused = " $( free ${ humanreadable } | awk '/Swap:/ {print $3}' ) " # string
swapfree = " $( free ${ humanreadable } | awk '/Swap:/ {print $4}' ) " # string
fi
### Disk information
## Available disk space on the partition.
filesystem = " $( LC_ALL = C df -hP " ${ rootdir } " | tail -n 1 | awk '{print $1}' ) "
totalspace = " $( LC_ALL = C df -hP " ${ rootdir } " | tail -n 1 | awk '{print $2}' ) "
usedspace = " $( LC_ALL = C df -hP " ${ rootdir } " | tail -n 1 | awk '{print $3}' ) "
availspace = " $( LC_ALL = C df -hP " ${ rootdir } " | tail -n 1 | awk '{print $4}' ) "
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}' ) " # string e.g 20G
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}' ) " # string e.g 5G
## LinuxGSM used space total.
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 [ " $( find " ${ backupdir } " -name "*.tar.gz" | wc -l) " -ne "0" ] ; then
# number of backups.
backupcount = " $( find " ${ backupdir } " /*.tar.gz | wc -l) "
backupcount = " $( find " ${ backupdir } " /*.tar.gz | wc -l) " # integer
# 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.
lastbackupdate = " $( date -r " ${ lastbackup } " ) "
lastbackupdate = " $( date -r " ${ lastbackup } " ) " # string
# 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.
lastbackupsize = " $( du -h " ${ lastbackup } " | awk '{print $1}' ) "
lastbackupsize = " $( du -h " ${ lastbackup } " | awk '{print $1}' ) " # string
fi
fi
# Network Interface name
netint = $( ${ ipcommand } -o addr | grep " ${ ip } " | awk '{print $2}' )
netlink = $( ${ ethtoolcommand } " ${ netint } " 2> /dev/null | grep Speed | 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}' ) # e.g 1000Mb/s
# Sets the SteamCMD glibc requirement if the game server requirement is less or not required.
if [ " ${ appid } " ] ; then
@ -286,5 +278,5 @@ if [ "${appid}" ]; then
fi
fi
# Gather Port Info using ss
# Gather Port Info using ss.
ssinfo = " $( ss -tuplwn) "