As long as Linux, through the Software warehouse (yum, apt-get, etc.) install Dmidecode, regardless of virtual machine, physical machine, execute the following command to obtain accurate memory raw capacity information.
Memory greater than 1G execution
#awk加入四舍五入的初衷是部分国产云虚机分配4G实际为3.99G, #做了四舍五入, VMware is accurate without rounding. or directly execute that command less than 1G dmidecode|grep-p-a5 "Memory Device" |grep Size | Grep-v No | awk ' {sum+=$2} END {printf "%.0fg\n", sum/1024} '
Memory is less than 1G or does not like rounding processing, want to draw the actual use of capacity, execute
Dmidecode|grep-p-a5 "Memory Device" |grep Size | Grep-v No | awk ' {sum+=$2} END {print sum ' M '} '
This article is from the "Grand Cloud Technology Record" blog, please make sure to keep this source http://xiayun.blog.51cto.com/2344243/1929466
Linux View accurate memory capacity command