Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 03-05-2007, 05:27 AM   #1
LQ Newbie
Registered: Mar 2007
Posts: 16

Rep: Reputation: 0
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.
Old 03-05-2007, 09:03 AM   #2
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
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.

Hope this helps.


cpu, linux, monitoring, proc, usage

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU usage from /proc/stat Rohan Nakar Linux - Newbie 3 01-25-2007 12:49 AM
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 08:43 PM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
finding cpu usage with /proc breadcrust Programming 16 06-18-2004 05:53 PM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 05:55 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration