Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-04-2003, 10:00 PM   #1
LQ Newbie
Registered: Jan 2003
Posts: 10

Rep: Reputation: 0
What /proc proc file do I need?

I need to write a program that displays the amount of time that the CPU has spent in user mode, system mode, and idle. I also need the number of disksrequests on the system, the number of context switches that the kernel has performed, and the number of processes that have been created since the system was booted. I know there should be /proc files that I can get this info from, but I don't know which ones. Can anyone help?
Old 02-04-2003, 11:52 PM   #2
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
Everything you want is in the "/proc/stat" file.

For the cpu time spent, there are CPU and CPU0 field.
cpu 177343 22777 24422 1344414
cpu0 177343 22777 24422 1344414

cpu is the overall time-spent and cpu0 is the per-cpu time-spent.
The numbers are in this format.

user, nice, system, idle

And "disk_io" field for the disk requests, "ctxt" for the context switches and "processes" field for the proceses.


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/sys/fs/file-nr ?? jharris Linux - General 5 07-27-2009 06:07 PM
Correlation between /proc/devices and /proc/modules ColinLadyka Linux - General 1 02-13-2006 05:25 PM
how proc file use to hibernation sajjadc Linux - Software 0 06-07-2005 01:06 PM
Reading from a /proc file russelh Programming 2 12-02-2004 05:30 PM
how do i compile /proc file? eltn Programming 12 10-20-2004 05:15 PM > Forums > Non-*NIX Forums > Programming

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