bluefreesky
welcome to my space
CPU usage: /proc/stat, etc?
January 9, 2009 on 2:26 pm | By | In bluefreesky.com | CPU usage: /proc/stat, etc?Is there a way?
sar -u 6 5
here CPU checkthe utilization 6 times in each 5 second.
Type the top command:
$ top
Output:
You can see Linux CPU utilization under CPU stats. The taskâ ™s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment (multiple CPUS), top will operate in number of CPUs. Please note that you need to type q key to exit the top command display.
You just need to sum the 2nd (user), 3rd (nice) and 4th (system) row, and divide it by all the available time (5th row is the idle time). Pseudo-code example:
tmp = $2 + $3 + $4
usage = $tmp / ($tmp + $5)
Simple, isn't it? ;-).
#If you have any other info about this subject , Please add it free.# |
edit