CentOS Calculate Memory CPU Correct method

Source: Internet
Author: User
Tags memory usage centos

Processor usage

Here you will extract four data from/proc/stat: User mode (users), low priority user mode (NICE), kernel mode (System), and idle processor Time (idle). They are all located on the first line of the/proc/stat file. CPU utilization is calculated using the following formula.

CPU Utilization = MB * (user + nice + system)/(user + nice + system + idle)

Free Memory =free+buffers+cached=total-used

Free memory =free memory +cached memory +buffers

True Memory Utilization = available memory/Total memory (note that the available memory here is calculated from the formula above, in fact, this result is already in the free command echo, that is, the echo result of the third row "-/+ buffers/cached", The second value of this row is the memory that is added to the buffers and cached, which is the available memory for the formula above.

You can use the free command in Linux to get the current system memory usage.

#busybox Free

Total used free shared buffers

mem:55636 52808 2828 0 3132

swap:0 0 0

total:55636 52808 2828

When I am full of joy typing the above command, received is a bursts of cold sweat, 2828k, my system is left with 2M more memory, the system can run, is not the command error!!!

Let's take a look at the results of the Linux system on the PC.

#free

Total used free shared buffers Cached

mem:4091524 4021016 70508 0 7656 1824312

-/+ buffers/cache:2189048 1902476

swap:4088532 2891732 1196800

Let me explain a few key concepts here.

Buffers: The main thing is to buffer a block device in a Linux system.

Cached: Used to buffer the files we open.

Memory is a valuable resource in the system, the idea of Linux is that if the memory is sufficient, it will use memory to cache some files, thus speeding up the process; when there is not enough memory, the memory will be recycled for program use.

So the real available memory =free+buffers+cached=70508+7656+1824312=1902476.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.