CPU, Memory usage in Linux from /proc
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.
Last edited by ruj.sabya; 03-05-2007 at 05:31 AM.