Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 09-26-2004, 06:33 PM   #1
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.


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

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


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 > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:17 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