44 lines
1.3 KiB
Plaintext
44 lines
1.3 KiB
Plaintext
|
|
||
|
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
|
||
|
|
||
|
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"
|
||
|
|
||
|
# 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)"
|
||
|
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
|
||
|
|