centos7使用的free命令版本更新后,和centos6的显示结果有差异,导致check_mem.sh脚本执行失败,研究调整后执行正常,上传不了,check_mem_r7.sh新版本,check_mem.sh老版本。
[root@TSP-GGLC-MQAINT ]# free -V
procps version 3.2.8
[root@TSP-GGLC-MQAINT ]# free -m
total used free shared buffers cached
Mem: 64418 9374 55044 0 319 8019
-/+ buffers/cache: 1035 63383
Swap: 9999 0 9999
[root@TSP-GGLC-MQAINT ]#
[root@onlinestore-nginx02 ]# free -V
free from procps-ng 3.3.10
[root@onlinestore-nginx02 ]# free -m
total used free shared buff/cache available
Mem: 63867 1503 526 3099 61837 58827
Swap: 36863 17 36846
[root@onlinestore-nginx02 ]#
调整内容如下:井号开头是原来的,下面行是新增的
memory=$(free -mt)
(( DEBUG )) && echo "memory=$memory"
##phyTotal=$(cut -d' ' -f 8 <<< $memory)
phyTotal=$(echo $memory | cut -d ' ' -f 8)
(( DEBUG )) && echo "phyTotal=$phyTotal"
##swpTotal=$(cut -d' ' -f 19 <<< $memory)
swpTotal=$(echo $memory | cut -d ' ' -f 15)
(( DEBUG )) && echo "swpTotal=$swpTotal"
##phyShared=$(cut -d' ' -f 11 <<< $memory)
phyShared=$(echo $memory | cut -d' ' -f 11)
(( DEBUG )) && echo "phyShared=$phyShared"
##phyBuffers=$(cut -d' ' -f 12 <<< $memory)
phyBuffers=$(awk '{if($1~"Buffers:") printf("%d\n",$2/1024)}' /proc/meminfo)
(( DEBUG )) && echo "phyBuffers=$phyBuffers"
##phyCached=$(cut -d' ' -f 13 <<< $memory)
phyCached=$(awk '{if($1~"^Cached:") printf("%d\n",$2/1024)}' /proc/meminfo)
(( DEBUG )) && echo "phyCached=$phyCached"
##phyUsed=$(cut -d' ' -f 16 <<< $memory)
phyUsed=$(echo $memory | cut -d ' ' -f 9)
(( DEBUG )) && echo "phyUsed=$phyUsed"
##phyAllUsed=$(cut -d' ' -f 9 <<< $memory)
phyAllUsed=$(echo $memory | cut -d' ' -f 9)
(( DEBUG )) && echo "phyAllUsed=$phyAllUsed"
##swpUsed=$(cut -d' ' -f 20 <<< $memory)
swpUsed=$(echo $memory | cut -d' ' -f 16)
(( DEBUG )) && echo "swpUsed=$swpUsed"