Test if swap is present
Signed-off-by: Alban Vidal <alban.vidal@zordhak.fr>
This commit is contained in:
parent
cd2a8d7ed8
commit
3c71fa06fb
@ -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}')
|
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
|
||||||
|
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) }'`
|
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", $3/$2*100) }'`
|
||||||
var4=${swap_usage%.*}
|
var4=${swap_usage%.*}
|
||||||
((var4 >= 1 )) && swap_usage="\033[31m$swap_usage\033[00m" || swap_usage="\033[32m$swap_usage\033[00m"
|
((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
|
||||||
|
|
||||||
|
|
||||||
# USERS AND OTHERS
|
# USERS AND OTHERS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user