System idle time under Linux
ifrit at underground
Thu Sep 30 10:22:31 CEST 2010
Ifrit heeft het volgende neergekrabbeld:
> Hugo Léveillé heeft het volgende neergekrabbeld:
>> Thanks, will take a closer look on that
>> But to get me started, how would you get, via python, the info from that
> From a unix command prompt use the cat command to view their contents.
> You'll notice that they plain text files with very informative content:
> # cat /proc/stat
And the man proc command gives info on the format of the content:
kernel/system statistics. Varies with architecture. Common
cpu 3357 0 4313 1362393
The amount of time, measured in units of USER_HZ
(1/100ths of a second on most architectures,
use sysconf(_SC_CLK_TCK) to obtain the right value),
that the system spent in user mode, user
mode with low priority (nice), system mode, and the
idle task, respectively. The last value
should be USER_HZ times the second entry in the uptime
In Linux 2.6 this line includes three additional
columns: iowait - time waiting for I/O to
complete (since 2.5.41); irq - time servicing
interrupts (since 2.6.0-test4); softirq - time
servicing softirqs (since 2.6.0-test4).
Since Linux 2.6.11, there is an eighth column, steal -
stolen time, which is the time spent in
other operating systems when running in a virtualized
Since Linux 2.6.24, there is a ninth column, guest,
which is the time spent running a virtual
CPU for guest operating systems under the control of
the Linux kernel.
page 5741 1808
The number of pages the system paged in and the number
that were paged out (from disk).
swap 1 0
The number of swap pages that have been brought in and
This line shows counts of interrupts serviced since
boot time, for each of the possible system
interrupts. The first column is the total of all
interrupts serviced; each subsequent column
is the total for a particular interrupt.
disk_io: (2,0):(31,30,5764,1,2) (3,0):...
(major,disk_idx):(noinfo, read_io_ops, blks_read,
(Linux 2.4 only)
The number of context switches that the system
boot time, in seconds since the Epoch (January 1,
Number of forks since boot.
Number of processes in runnable state. (Linux 2.5.45
Number of processes blocked waiting for I/O to
complete. (Linux 2.5.45 onwards.)
More information about the Python-list