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.