[root@shell jao]
MEM_TOTAL=`free -h |awk 'NR==2{print $2}'`
MEM_USE=`free -h |awk 'NR==2{print $3}'`
MEM_USED=`free | grep -i mem |awk '{print $3/$2*100"%"}'`
MEM_FREE=`free -h |awk 'NR==2{print $4}'`
MEM_FREED=`free | grep -i mem |awk '{print $4/$2*100"%"}'`
MEM_BUFF_CACHE=`free -h |awk 'NR==2{print $6}'`
MEM_BUFF_CACHED=`free | grep -i mem |awk '{print $6/$2*100 "%"}'`
MEM_SHARE=`free -h |awk 'NR==2{print $5}'`
MEM_SHARED=`free | grep -i mem |awk '{print $5/$2*100 "%"}'`
MEM_ZONE=`head -3 /proc/meminfo | awk 'NR==1{t=$2}NR==2{f=$2;print(t-f)*100/t"%"}'`
echo -e "\t\e[1;32m内存总量: $MEM_TOTAL \e[0m"
echo -e "\t\e[1;32m内存总量减剩余内存(所有已使用)占比: $MEM_ZONE \e[0m"
echo -e "\t\e[1;32m已使用: $MEM_USE 占比: $MEM_USED \e[0m"
echo -e "\t\e[1;32m剩 余: $MEM_FREE 占比: $MEM_FREED \e[0m"
echo -e "\t\e[1;32m共 享: $MEM_SHARE 占比: $MEM_SHARED \e[0m"
echo -e "\t\e[1;32m缓冲区: $MEM_BUFF_CACHE 占比: $MEM_BUFF_CACHED \e[0m"
|