<commit_before>#!/bin/bash
# LGSM info_distro.sh function
# Author: <NAME>
# Website: https://gameservermanagers.com
# Description: Variables providing useful info on the Operating System such as disk and performace info.
# Used for command_details.sh, command_debug.sh and alert.sh.

local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"

### 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
	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
# e.g: 1.17
glibcversion="$(ldd --version | sed -n '1s/.* //p')"

## tmux version
# e.g: tmux 1.6
if [ -z "$(command -v tmux)" ]; then
	tmuxv="${red}NOT INSTALLED!${default}"
elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then
	tmuxv="$(tmux -V) (>= 1.6 required for console log)"
else
	tmuxv=$(tmux -V)
fi

## 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
load=$(uptime|awk -F 'load average: ' '{ print $2 }')

## 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
	humanreadable="-m"
else
	humanreadable="-h"
fi

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}')

## LGSM used space total.
rootdirdu=$(du -sh "${rootdir}" 2> /dev/null | awk '{print $1}')
if [ -z "${rootdirdu}" ]; then<commit_msg>Added cached memory varible<commit_after>#!/bin/bash
# LGSM info_distro.sh function
# Author: <NAME>
# Website: https://gameservermanagers.com
# Description: Variables providing useful info on the Operating System such as disk and performace info.
# Used for command_details.sh, command_debug.sh and alert.sh.

local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"

### 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
	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
# e.g: 1.17
glibcversion="$(ldd --version | sed -n '1s/.* //p')"

## tmux version
# e.g: tmux 1.6
if [ -z "$(command -v tmux)" ]; then
	tmuxv="${red}NOT INSTALLED!${default}"
elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then
	tmuxv="$(tmux -V) (>= 1.6 required for console log)"
else
	tmuxv=$(tmux -V)
fi

## 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
load=$(uptime|awk -F 'load average: ' '{ print $2 }')

## 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
	humanreadable="-m"
else
	humanreadable="-h"
fi

physmemtotal=$(free ${humanreadable} | awk '/Mem:/ {print $2}')
physmemused=$(free ${humanreadable} | awk '/Mem:/ {print $3}')
physmemfree=$(free ${humanreadable} | awk '/Mem:/ {print $4}')
pysmemcached=$(free ${humanreadable} | awk '/cache:/ {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}')

## LGSM used space total.
rootdirdu=$(du -sh "${rootdir}" 2> /dev/null | awk '{print $1}')
if [ -z "${rootdirdu}" ]; then
{'fraction_non_alphanumeric': 0.21857258718572586, 'fraction_numerical': 0.018045417680454177, 'mean_word_length': 4.35613463626493, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6174958', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1818, 'n_words': 538}