api to get CPU utilization

Hi,

I am looking for api to get CPU utilization in linux.
I want use that api in c++ program.
anyone plz help me..
Last edited on
Most programs (like top) just read /proc/stat which contains, on a per CPU-basis, the
breakdown of how each CPU spent its time since last reboot.

Read the file twice, one second apart, and subtract the values. Divide the results
by 1000 (the values are in msecs) and you get CPU utilizations.
Topic archived. No new replies allowed.