How is CPU usage calculated on a Linux system with a single core?
Cpu(s): 28.1%us, 6.5%sy, 0.0%ni, 43.0%id, 21.6%wa, 0.0%hi, 0.5%si, 0.2%st
Please explain me how the us
, sy
, ni
, id
, wa
, hi
, si
and st
values are obtained.
How is CPU usage calculated on a Linux system with a single core?
Cpu(s): 28.1%us, 6.5%sy, 0.0%ni, 43.0%id, 21.6%wa, 0.0%hi, 0.5%si, 0.2%st
Please explain me how the us
, sy
, ni
, id
, wa
, hi
, si
and st
values are obtained.
CPU usage is calculated and tracked by the kernel. The exact methods and processes involved in this are far beyond the scope of this site (ServerFault).
If you're wondering what the values represent, I pulled this nice list from IBM's site, though the full article is a good read:
(from IBM... why it's only embedded in a Java SDK guide is beyond me)
top
gets its information from the /proc directory, which is a special directory used to query the kernel for, among other things, process statistics.man proc
can give you more information on how /proc is set up./proc/[pid]/stat results are produced by this code in the Linux kernel.
http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/fs/proc/stat.c
You can click around and get more info from in there.
This article describes this clearly.
http://www.linuxjournal.com/article/9001