diff --git a/root/.profile.d/01_stats_connexion.conf b/root/.profile.d/01_stats_connexion.conf index 5c4f613..2da15dc 100644 --- a/root/.profile.d/01_stats_connexion.conf +++ b/root/.profile.d/01_stats_connexion.conf @@ -16,10 +16,16 @@ swapiness=`sysctl vm.swappiness |awk '{print $3}'` 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 +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 -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