LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices



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

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

Last edited by ruj.sabya; 03-05-2007 at 06:31 AM.
 
Old 03-05-2007, 10:03 AM   #2
wjevans_7d1@yahoo.co
Member
 
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.

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

Hope this helps.
 
  


Reply

Tags
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 01:49 AM
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 09: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 05:45 AM
finding cpu usage with /proc breadcrust Programming 16 06-18-2004 06:53 PM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 06:55 AM


All times are GMT -5. The time now is 12:57 AM.

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