Discussion Locked

CPU Usage percentage

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How to caluculate system% user% busy% wait% idle% of cpu in LINUX environment

7 replies

by joe prochazka

Try Running top
[root@darkstar /root]# top
this will give you not only the information you are looking for but also give the information on all processes currently running on your machine.

by ks_moorthy

I know about top utiltiy. I am in need to write some script or c program rahter than using top .And moreover i know these things are available in /proc/stat.
My question is from this data how to calculate % ces .

by dallen

If you have the Gnome enviorment you may also try running:
gtop&
this will launch a GUI console, as a backround process.

by bruce timberlake

There is not a simple what to do it. The raw cpu times per state you can get by reading the 'cpu' line from /proc/stat. There are 4 numbers which represent user, nice, system, and idle.

To get CPU usage your have to read /proc/stat twice over a period of time. Calculate the delta for each CPU state. To get percentages for each state, divide each state delta by the sum of all 4 delta deltas. To get CPU busy percentage divide the sum of user, nice, and system by the sum of all 4 deltas.

This method is how the top command calculates it's CPU percentages.

This discussion is closed to new replies.