Просмотр исходного кода

Added LGSM total disk used and tidy up

Daniel Gibbs 10 лет назад
Родитель
Сommit
58b3f6301e
2 измененных файлов с 57 добавлено и 33 удалено
  1. 4 1
      lgsm/functions/command_details.sh
  2. 53 32
      lgsm/functions/info_distro.sh

+ 4 - 1
lgsm/functions/command_details.sh

@@ -2,7 +2,7 @@
 # LGSM command_details.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+lgsm_version="190616"
 
 # Description: Displays server infomation.
 
@@ -69,7 +69,9 @@ fn_details_disk(){
 	# Total:        15G
 	# Used:         8.4G
 	# Available:    5.7G
+	# LGSM Total:	1G
 	# Serverfiles:  961M
+	# Backups:  	2G
 
 	echo -e ""
 	echo -e "\e[93mStorage\e[0m"
@@ -79,6 +81,7 @@ fn_details_disk(){
 		echo -e "\e[34mTotal:\t\e[0m${totalspace}"
 		echo -e "\e[34mUsed:\t\e[0m${usedspace}"
 		echo -e "\e[34mAvailable:\t\e[0m${availspace}"
+		echo -e "\e[34mLGSM Total:\t\e[0m${rootdirdu}"
 		echo -e "\e[34mServerfiles:\t\e[0m${filesdirdu}"
 		if [ -d "${backupdir}" ]; then
 			echo -e "\e[34mBackups:\t\e[0m${backupdirdu}"

+ 53 - 32
lgsm/functions/info_distro.sh

@@ -2,30 +2,33 @@
 # LGSM info_distro.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+lgsm_version="190616"
 
 # Description: Variables providing useful info on the Operating System such as disk and performace info.
-# Used for command_details.sh, command_debug.sh and email.sh.
+# Used for command_details.sh, command_debug.sh and alert.sh.
 
-## Distro infomation
+
+### Distro infomation
+
+## Distro
 # Returns architecture, kernel and distro/os.
 arch=$(uname -m)
 kernel=$(uname -r)
 if [ -n "$(command -v lsb_release)" ]; then
 	os=$(lsb_release -s -d)
-elif [ -f /etc/debian_version ]; then
+elif [ -f "/etc/debian_version" ]; then
 	os="Debian $(cat /etc/debian_version)"
-elif [ -f /etc/redhat-release ]; then
+elif [ -f "/etc/redhat-release" ]; then
 	os=$(cat /etc/redhat-release)
 else
 	os="$(uname -s) $(uname -r)"
 fi
 
-# Glibc version number
+## Glibc version
 # e.g: 1.17
 glibcversion="$(ldd --version | sed -n '1s/.* //p')"
 
-# tmux version
+## tmux version
 # e.g: tmux 1.6
 if [ -z "$(command -v tmux)" ]; then
 	tmuxv="\e[0;31mNOT INSTALLED!\e[0m"
@@ -35,53 +38,71 @@ else
 	tmuxv=$(tmux -V)
 fi
 
-## Performance
+## Uptime
+uptime=$(</proc/uptime)
+uptime=${uptime/[. ]*/}
+minutes=$(( uptime/60%60 ))
+hours=$(( uptime/60/60%24 ))
+days=$(( uptime/60/60/24 ))
+
+
+### Performance infomation
 
-# Average server load
+## Average server load
 load=$(uptime|awk -F 'load average: ' '{ print $2 }')
 
-# Memory
+## Memory Infomation
+# Available RAM and swap.
 
 # Older versions of free do not support -h option.
 if [ "$(free -h > /dev/null 2>&1; echo $?)" -ne "0" ]; then
-	option="-m"
+	humanreadable="-m"
 else
-	option="-h"
+	humanreadable="-h"
 fi
-physmemtotal=$(free ${option} | awk '/Mem:/ {print $2}')
-physmemused=$(free ${option} | awk '/Mem:/ {print $3}')
-physmemfree=$(free ${option} | awk '/Mem:/ {print $4}')
-swaptotal=$(free ${option} | awk '/Swap:/ {print $2}')
-swapused=$(free ${option} | awk '/Swap:/ {print $3}')
-swapfree=$(free ${option} | awk '/Swap:/ {print $4}')
-
-# Uptime
-uptime=$(</proc/uptime)
-uptime=${uptime/[. ]*/}
-minutes=$(( uptime/60%60 ))
-hours=$(( uptime/60/60%24 ))
-days=$(( uptime/60/60/24 ))
 
-# Disk usage
-# available space on the partition.
+physmemtotal=$(free ${humanreadable} | awk '/Mem:/ {print $2}')
+physmemused=$(free ${humanreadable} | awk '/Mem:/ {print $3}')
+physmemfree=$(free ${humanreadable} | awk '/Mem:/ {print $4}')
+swaptotal=$(free ${humanreadable} | awk '/Swap:/ {print $2}')
+swapused=$(free ${humanreadable} | awk '/Swap:/ {print $3}')
+swapfree=$(free ${humanreadable} | awk '/Swap:/ {print $4}')
+
+
+### Disk Infomation
+
+## Available disk space on the partition.
 filesystem=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $1}')
 totalspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $2}')
 usedspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $3}')
 availspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $4}')
 
-# used space in serverfiles dir.
+## LGSM used space total.
+rootdirdu=$(du -sh "${rootdir}" 2> /dev/null | awk '{print $1}')
+if [ -z "${rootdirdu}" ]; then
+	rootdirdu="0M"
+fi
+
+## LGSM used space in serverfiles dir.
 filesdirdu=$(du -sh "${filesdir}" 2> /dev/null | awk '{print $1}')
-if [ -z ${filesdirdu} ]; then
+if [ -z "${filesdirdu}" ]; then
 	filesdirdu="0M"
 fi
 
-# Backup info
+## LGSM used space total minus backup dir.
+rootdirduexbackup=$(du -sh --exclude="${backupdir}" "${filesdir}" 2> /dev/null | awk '{print $1}')
+if [ -z "${rootdirduexbackup}" ]; then
+	rootdirduexbackup="0M"
+fi
+
+## Backup info
 if [ -d "${backupdir}" ]; then
 	# used space in backups dir.
 	backupdirdu=$(du -sh "${backupdir}" | awk '{print $1}')
-	if [ -z ${backupdirdu} ]; then
+	if [ -z "${backupdirdu}" ]; then
 		backupdirdu="0M"
 	fi
+
 	# number of backups.
 	backupcount=$(find "${backupdir}"/*.tar.gz | wc -l)
 	# most recent backup.
@@ -91,4 +112,4 @@ if [ -d "${backupdir}" ]; then
 	# size of most recent backup.
 	lastbackupsize=$(du -h "${lastbackup}" | awk '{print $1}')
 
-fi
+fi