I../PROC CATALOGUE
The/proc directory on a Linux system is a file system, the proc file system, unlike other common file systems, the/proc file system is a pseudo-file system that only exists in memory and does not occupy external memory space. It provides the interface for the kernel to communicate with the process in a file system manner . Users and applications can get system information through/PROC, and can change certain parameters of the kernel. Because the information of the system, such as the process, is dynamically changed, so when a user or application reads a file from the/proc directory, the proc file system dynamically reads the required information from the system kernel and submits it.
Second,/proc/stat and top of the CPU information 1. /proc/stat
The file contains information about all CPU activity, and all values in the file are accumulated from the start of the system to the current moment . The format of the file may be inconsistent in different kernel versions, and the following examples illustrate the meaning of each field in the data file. (Kernel 2.6.32-431 version)
[[email protected] proc]# Cat/proc/statcpu638 0 1677 868357 2397 7 510 0 0cpu0638 0 1677 868357 2397 7 510 0 0... (omitted later)
The value of the first line represents the total CPU usage, and the meanings of the values are as follows:
Parameters |
Parsing (unit: jiffies) |
User (638) |
Accumulated from the start of the system to the current moment, in the user-state run time, does not include the nice value is a negative process. |
Nice (0) |
The CPU time occupied by a process that has a negative nice value from the beginning of the system startup to the current moment |
System (1677) |
Accumulated from the start of the system to the current moment, the running time of the nuclear mentality |
Idle (868357) |
Accumulate from the start of the system to the current moment, waiting time other than IO wait time |
Iowait (2397) |
Accumulated from the start of the system to the current time, IO wait time (since 2.5.41) |
IRQ (7) |
Accumulated from the start of the system to the current moment, hard interrupt time (since 2.6.0-TEST4) |
SOFTIRQ (510) |
Accumulated from the start of the system to the current moment, soft interrupt time (since 2.6.0-TEST4) |
Steal (0) |
Accumulates from the start of the system to the current moment, which is the time spent on other operating systems while running in a virtual environment. (Since Linux 2.6.11) |
Guest (0) |
The time to run the virtual CPU for the client operating system under the control of the Linux kernel, from the beginning of the system startup to the current moment. (Since Linux 2.6.24) |
(jiffies is a global variable in the kernel, used to record the number of Beats generated from the start of the system, in Linux, a beat is roughly understood as the minimum time slice of the operating system process scheduling, different Linux cores may have different values, usually between 1ms to 10ms)
Total CPU Time:totalcputime = user + nice + system + Idle + iowait + IRQ + SOFTIRQ + Stealstolen + Guest.
As you can see, the time recorded in the stat file is all the CPU time accumulated from booting to the current time.
2. Top CPU Information
Enter the top command, and the output is as follows:
Top - xx: the: $Up2: -,1 User,LoadAverage0.00,0.00,0.00Tasks: theTotal1Running theSleeping,0Stopped0Zombiecpu (s):0.3%us0.3%Sy0.0%Ni99.3%Id0.0%Uan0.0%Hi0.0%Qin0.0%St ..... (omitted)
Cup (s) the meaning of the line is as follows:
Kernel space consumption CPU percentage
0.3%us |
User space occupied CPU percentage |
0.3%sy |
0.0%ni |
Change in user process space CPU percent of process consuming priority |
99.3%id |
Idle cpu percent |
0.0%wa |
% CPU time waiting for input and output |
0.0%hi |
Hard interrupt (Hardware IRQ)% CPU occupied |
%si |
Soft interrupt (software interrupts)% CPU occupied |
0.0%st |
Time spent on other operating systems when running in a virtual environment |
As you can see, the CPU information displayed in top is the percentage of CPU that is consumed by various parameters in real time .
3. The connection and difference between/proc/stat and top CPU information
difference:The/proc/stat file shows the cumulative value of various cup times from start to current time, while top shows real-time CPU usage.
Contact:Top calculates CPU usage by reading/proc/stat.
/proc/stat is like the number of miles on a car dashboard, and the CPU information on top shows the speed of the car.
Third, reference
1. Compute CPU usage in Linux with/proc/stat and other files
2. Linux/proc Catalogue
3. Linux:/proc/stat info isn't consistent with top command
4. Top command detailed CPU view multiple cores utilization by 1
5. Linux Top Command parsing
Finish
The connection and difference between the/proc/stat information of Linux system and the Cup information of top