فهرست منبع

Added new function fn_distrodetails

fn_distrodetails to replace 3  functions and provide more in depth info
for fn_details and other functions that require distro and game server
info.

fn_load, fn_uptime and fn_distro are being depricated
Daniel Gibbs 11 سال پیش
والد
کامیت
09c97be831
5فایلهای تغییر یافته به همراه95 افزوده شده و 4 حذف شده
  1. 2 1
      functions/fn_distro
  2. 81 0
      functions/fn_distrodetails
  3. 8 1
      functions/fn_functions
  4. 2 1
      functions/fn_load
  5. 2 1
      functions/fn_uptime

+ 2 - 1
functions/fn_distro

@@ -2,7 +2,8 @@
 # LGSM fn_distro function
 # LGSM fn_distro function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 141214
+# Depricated: fn_distrodetails has replaced this function.
 
 
 arch=$(uname -m)
 arch=$(uname -m)
 kernel=$(uname -r)
 kernel=$(uname -r)

+ 81 - 0
functions/fn_distrodetails

@@ -0,0 +1,81 @@
+#!/bin/bash
+# LGSM fn_distrodetails function
+# Author: Daniel Gibbs
+# Website: http://danielgibbs.co.uk
+# Version: 141214
+
+# Description: Variables providing useful info on the Operating System such as disk and performace info.
+# Used for fn_details, fn_debugserver and fn_emailnotification.
+
+# Distro infomation
+# Returns architecture, kernel and distro/os
+arch=$(uname -m)
+kernel=$(uname -r)
+if [ -f /etc/lsb-release ]; then
+	os=$(lsb_release -s -d)
+elif [ -f /etc/debian_version ]; then
+	os="Debian $(cat /etc/debian_version)"
+elif [ -f /etc/redhat-release ]; then
+	os=$(cat /etc/redhat-release)
+else
+	os="$(uname -s) $(uname -r)"
+fi
+
+# Glibc version number
+# e.g: 1.17
+glibcv=$(ldd --version |grep ldd|awk '{print $NF}')
+
+# tmux version
+# e.g: tmux 1.6
+if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd [:digit:]|tail -c 3)" -lt "16" ]; then
+	tmuxv="$(tmux -V) (>= 1.6 required for console log)"
+else
+	tmuxv=$(tmux -V)
+fi
+
+# Performance
+
+# Average server load
+load=$(uptime|awk -F 'load average: ' '{ print $2 }')
+
+# Memory
+physmemtotal=$(free -h|grep "Mem:" | awk '{print $2}')
+physmemused=$(free -h|grep "Mem:" | awk '{print $3}')
+physmemfree=$(free -h|grep "Mem:" | awk '{print $4}')
+swaptotal=$(free -h|grep "Swap:" | awk '{print $2}')
+swapused=$(free -h|grep "Swap:" | awk '{print $3}')
+swapfree=$(free -h|grep "Swap:" | awk '{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
+availspace=$(df -hP ${rootdir} | grep -v "Filesystem" | awk '{print $4}')
+# used space in serverfiles dir
+serverfilesdu=$(du -sh ${serverfiles} | awk '{print $1}')
+if [ -z ${serverfilesdu} ]; then
+	serverfilesdu="0M"
+fi
+
+# Backup info
+if [ -d "${backupdir}" ]; then
+	# used space in backups dir
+	backupdirdu=$(du -sh ${backupdir} | awk '{print $1}')
+	if [ -z ${backupdirdu} ]; then
+		backupdirdu="0M"
+	fi
+	# number of backups
+	backupcount=$(find "${backupdir}"/*.tar.gz | wc -l)
+	# most recent backup
+	lastbackup=$(ls -t "${backupdir}"/*.tar.gz | head -1)
+	# date of most recent backup
+	lastbackupdate=$(date -r ${lastbackup})
+	# size of most recent backup
+	lastbackupsize=$(du -h "${lastbackup}" | awk '{print $1}')
+
+fi

+ 8 - 1
functions/fn_functions

@@ -2,7 +2,7 @@
 # LGSM fn_functions function
 # LGSM fn_functions function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
 # Website: http://danielgibbs.co.uk
-# Version: 040115
+# Version: 150115
 
 
 # Description: Defines all functions to allow download and execution of functions using fn_runfunction.
 # Description: Defines all functions to allow download and execution of functions using fn_runfunction.
 # This function is called first before any other function. Without this file other functions would not load.
 # This function is called first before any other function. Without this file other functions would not load.
@@ -32,11 +32,16 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 fn_runfunction
 }
 }
 
 
+# Depricated: fn_distrodetails has replaced this function.
 fn_distro(){
 fn_distro(){
 functionfile="${FUNCNAME}"
 functionfile="${FUNCNAME}"
 fn_runfunction
 fn_runfunction
 }
 }
 
 
+fn_distrodetails(){
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
 fn_emailnotification(){
 fn_emailnotification(){
 functionfile="${FUNCNAME}"
 functionfile="${FUNCNAME}"
 fn_runfunction
 fn_runfunction
@@ -47,6 +52,7 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 fn_runfunction
 }
 }
 
 
+# Depricated: fn_distrodetails has replaced this function.
 fn_load(){
 fn_load(){
 functionfile="${FUNCNAME}"
 functionfile="${FUNCNAME}"
 fn_runfunction
 fn_runfunction
@@ -119,6 +125,7 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 fn_runfunction
 }
 }
 
 
+# Depricated: fn_distrodetails has replaced this function.
 fn_uptime(){
 fn_uptime(){
 functionfile="${FUNCNAME}"
 functionfile="${FUNCNAME}"
 fn_runfunction
 fn_runfunction

+ 2 - 1
functions/fn_load

@@ -2,6 +2,7 @@
 # LGSM fn_load function
 # LGSM fn_load function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 141214
+# Depricated: fn_distrodetails has replaced this function.
 
 
 load=$(uptime|awk -F 'load average' '{ print $2 }')
 load=$(uptime|awk -F 'load average' '{ print $2 }')

+ 2 - 1
functions/fn_uptime

@@ -2,7 +2,8 @@
 # LGSM fn_uptime function
 # LGSM fn_uptime function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 141214
+# Depricated: fn_distrodetails has replaced this function.
 
 
 uptime=$(</proc/uptime)
 uptime=$(</proc/uptime)
 uptime=${uptime%%.*}
 uptime=${uptime%%.*}