2018-05-30 01:03:27 +02:00
|
|
|
|
|
|
|
date=`date +"%Y-%m-%d - %T"`
|
|
|
|
|
|
|
|
# LOAD AVERAGE
|
|
|
|
|
|
|
|
load=$(cat /proc/loadavg |awk -v red="$(tput setaf 1)" -v yellow="$(tput setaf 3)" -v green="$(tput setaf 2)" -v reset="$(tput sgr0)" '{printf "%s%s%s\n", (+$1>1?red:(+$1>0.7)?yellow:green), $1, reset}')
|
|
|
|
|
|
|
|
# CALCULATE SWAPINESS FOR MEMOIRE ET SWAP
|
|
|
|
|
|
|
|
swapiness=`sysctl vm.swappiness |awk '{print $3}'`
|
|
|
|
(( swapiness = 100 - swapiness))
|
|
|
|
(( mi_swapiness = swapiness / 2 ))
|
|
|
|
|
|
|
|
# MEMORY
|
|
|
|
|
|
|
|
memory_usage=$(free -m| grep 'Mem' |awk ' {total=$2} {avalaible=$7} END { printf("%3.1f%%", 100-avalaible/total*100)}' |awk -v red="$(tput setaf 1)" -v yellow="$(tput setaf 3)" -v green="$(tput setaf 2)" -v reset="$(tput sgr0)" '{printf "%s%s%s\n", (+$1>'$swapiness'?red:(+$1>'$mi_swapiness')?yellow:green), $1, reset}')
|
|
|
|
|
|
|
|
# SWAP
|
2018-05-30 08:24:00 +02:00
|
|
|
if [ $(grep SwapTotal /proc/meminfo |awk '{print $2}') -gt 0 ] ; then
|
|
|
|
# if swap exist
|
|
|
|
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", $3/$2*100) }'`
|
|
|
|
var4=${swap_usage%.*}
|
|
|
|
((var4 >= 1 )) && swap_usage="\033[31m$swap_usage\033[00m" || swap_usage="\033[32m$swap_usage\033[00m"
|
|
|
|
else
|
|
|
|
# if swap is absent
|
|
|
|
swap_usage="NO SWAP"
|
|
|
|
fi
|
2018-05-30 01:03:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
# USERS AND OTHERS
|
|
|
|
|
|
|
|
users=`users | wc -w`
|
|
|
|
processes=`ps aux | wc -l`
|
|
|
|
|
|
|
|
############# SHOW #############
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo -e "OS\t:\t `lsb_release -d | sed -e 's/Description://g' | sed 's/^[ \t]*//'`"
|
|
|
|
echo -e "Uptime\t:\t $(uptime -p)"
|
2018-06-12 12:07:27 +02:00
|
|
|
echo
|
2018-05-30 01:03:27 +02:00
|
|
|
ip4all
|
|
|
|
echo
|
|
|
|
hddtop
|
|
|
|
echo
|
|
|
|
echo -e "CPU Load\t:\t$load"
|
|
|
|
echo -e "Memory usage\t:\t$memory_usage"
|
|
|
|
echo -e "Swap usage\t:\t$swap_usage"
|
|
|
|
echo -e "Process number\t:\t$processes"
|
|
|
|
echo
|
|
|
|
|
2018-05-30 12:19:15 +02:00
|
|
|
# If reboot is required
|
|
|
|
if [ -f /run/reboot-required ] ; then
|
|
|
|
echo -e "$(tput setaf 1)\tReboot is required$(tput sgr0)"
|
|
|
|
fi
|
|
|
|
|