LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   CPU, Memory usage in Linux from /proc (https://www.linuxquestions.org/questions/linux-general-1/cpu-memory-usage-in-linux-from-proc-534697/)

ruj.sabya 03-05-2007 05:27 AM

CPU, Memory usage in Linux from /proc
 
Hello,

I want to calculate '% of overall cpu usage' and '% of cpu used by a process' at the point of time. The computers is Linux (Assuming kernel above 2.4.3). So how should I calculate these?


And same for physical memory. I got the overall memory usage (from /proc/meminfo). But am not sure how to calculate it for a specific process. I calculated it for a number of process like:-

Took total memory size(MemTotal) form /proc/meminfo and RES size of process (VmRSS) from /proc/[process_id]/status

Then I am doing "(VmRSS/MemTotal)*100". Is it correct calculation for memory usage of a process? I think this will not add up the data/stack in the memory created by the process. So if I need to calculate total used memory of process what things I need from /proc?

I dont want to use 'top' command.

Sabyasachi.

wjevans_7d1@yahoo.co 03-05-2007 09:03 AM

So don't use the 'top' command. But do look at the source code for the 'top' command, to see how William LeFebvre did what you want to do.

http://www.fysh.org/~chris/top/

Hope this helps.


All times are GMT -5. The time now is 08:17 AM.