LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-26-2004, 06:33 PM   #1
ziggyboy
LQ Newbie
 
Registered: May 2004
Location: Australia
Distribution: Slackware
Posts: 12

Rep: Reputation: 0
Computing CPU usage from /proc


Does anyone know how to manually compute the CPU usage using /proc? I was told /proc/stat would do the trick but I'm not sure how to play around with the jiffy values.

Thanks.

Last edited by ziggyboy; 09-26-2004 at 06:37 PM.
 
Old 09-27-2004, 01:52 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 67
There are several programs that do this, including iostat.

You can find details of the format or /proc/stat in section 1.8 (in my installation at least) of /usr/src/linux/Documentation/filesystems/proc.txt, or google search for filesystems/proc.txt

I should point out that the CPU usage isn't a very measurable quantity; at any point in time a CPU either is being used (executing code), or it isn't (waiting, context-switching, powered down), so the numbers only make sense over time. /proc/stat contains the total values since power-up I think.

Basically, the fourth field is the proportion of time spent idle, the ones before it are working, and the ones after it are waiting for/dealing with hardware. Plot these on a pie chart, and that's your average CPU usage.

Programs like top take the difference in these values sampled every two seconds, to work it out for over a shorter length of time.
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/proc/stat file problem for cpu usage arunka Programming 3 04-23-2014 02:08 PM
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
Calculating total %cpu usage from /proc/stat gaijin Programming 1 07-07-2004 03:45 AM
finding cpu usage with /proc breadcrust Programming 16 06-18-2004 06:53 PM


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

Main Menu
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