Memory and CPU calculation for Linux

How is the memory and CPU percentage for every process calculated for a Linux server monitor?

The CPU percentage for every process is calculated using the formula given below:

ProcessCPU% = (((val2 - val1) / (time2 - time1)) * 100) / NumberOfLogicalProcessors
where,
val1 is the CPU percentage of the process taken at time 1

val2 is the CPU percentage of the process taken at time 1

The memory percentage for every process is calculated using the below formula:
ProcessMemory% = ((WorkingSetSize of the process) * 100) / (TotalVisibleMemorySize of the entire machine * 1024)



Related Articles: