About /proc/stat ???

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Dec 2007
Posts: 2
Reputation: Vagelis44 is an unknown quantity at this point 
Solved Threads: 0
Vagelis44 Vagelis44 is offline Offline
Newbie Poster

About /proc/stat ???

 
0
  #1
Jan 12th, 2008
Hi,
I want to make some kind of monitor for my PC and i want to have CPU load in form like "top" (something% , ex 23%).
So i use C and : i'm opening the file /proc/stat and read the first line :
cpu 92208 2282668 19432 79824 739 1441 3304

the first is user, nice , system ...

So does anyone knows how this things can show me the percentage of CPU usage like "top" does?
thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 71
Reputation: Belrog is an unknown quantity at this point 
Solved Threads: 4
Belrog's Avatar
Belrog Belrog is offline Offline
Junior Poster in Training

Re: About /proc/stat ???

 
0
  #2
Jan 14th, 2008
It might be easier to just use /proc/loadavg if you only need the cpu load. This matches exactly with 'top'
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC