Linux CPU real-time monitoring command mpstat introduction

  
 

1, Introduction mpstat is an abbreviation of Multiprocessor Statistics, which is a real-time system monitoring tool. The report is some statistics of the CPU, which is stored in the /proc/stat file. In a multi-CPUs system, it can view not only the average status information of all CPUs, but also the information of a specific CPU. The biggest feature of mpstat is that you can view the statistics of each computing core in the multi-core cpu; similar tools vmstat can only view the overall cpu of the system.

2, install [root@ora10g ~]# mpstat-bash: mpstat: command not found[root@ora10g ~]# mount -o loop -t iso9660 /dev/cdrom /mnt/cdrom[root@ Ora10g ~]# cd /mnt/cdrom/Server/[root@ora10g Server]# rpm -ivh sysstat-7.0.2-3.el5.i386.rpm warning: sysstat-7.0.2-3.el5.i386.rpm : Header V3 DSA signature: NOKEY, key ID 37017186Preparing... ################################################## ####### [100%]1:sysstat ########################################################## ####### [100%]

3, example usage mpstat -V displays mpstat version information mpstat -P ALL displays all CPU information mpstat -P n displays the nth cup information, n is a number Counts from 0 to mpstat nm. Display cpu information once every n seconds, display m times in succession, and finally display an average value mpstat n. Display cpu information once every n seconds. Continue to display the detailed current status of each cpu core. Information, the output is as follows: [root@ora10g ~]# mpstat -P ALLLinux 2.6.18-194.el5 (ora10g.up.com) 11/05/1409:13:02 CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s09:13:02 all 0.62 0.01 0.54 3.4 8 0.00 0.02 0.00 95.32 1039.5809:13:02 0 0.92 0.01 1.18 8.77 0.01 0.05 0.00 89.06 1030.2309:13:02 1 0.27 0.00 0.31 1.46 0.00 0.01 0.00 97.96 1.00....09:13:02 14 1.12 0.02 0.45 2.99 0.00 0.01 0.00 95.39 7.7409:13:02 15 0.18 0.00 0.22 0.70 0.00 0.01 0.00 98.90 0.59

Check the current health status of the multi-core CPU core and update it every 2 seconds [root@ora10g ~]# mpstat -P ALL 2

Check the usage of a cpu, the value is in [0, cpu number-1] [root@ora10g ~]# mpstat -P 2Linux 2.6.18-194.el5 (ora10g.up .com) 11/05/1410:19:28 CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s10:19:28 2 0.08 0.00 0.04 0.22 0.00 0.01 0.00 99.64 0.55

View the current running status of the multi-core CPU core, update every 2 seconds, display 5 times [root@ora10g ~]# mpstat -P ALL 2 5

4, the meaning of the field is as follows: CPU: Processor keyword. The keyword all indicates that statistics are calculated as averages among all processors.%user:Show the percentage of CPU utilization that occurred while executing At the user level (application).%nice:Show the percentage of CPU utilization that occurred while executing at the user level with nice priority.%sys:Show the percentage of CPU utilization that occurred while executing at the system level (kernel). Note that this does not include time spent servicing interrupts or softirqs.%iowait:Show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.%irq:Show the percentage of time spent by The CPU or CPUs to service interrupts.%soft:Show the percentage of time spent by the CPU or CPUs to service softirqs. A softirq (software interrupt) isone of up to 32 enumerated software interrupts which can run on multiple CPUs at once.% Steal:Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was ser-vicing another virtual processor.%idle:Show the percentage of time that the CPU or CPUs were idle and the system did not have an Outstandin g disk I/O request.intr/s:Show the total number of interrupts received per second by the CPU or CPUs.

Parameter interpretation Get data from /proc/stat CPU processor IDuser in the internal time period , user mode CPU time (%), does not contain nice value negative process (usr/total) * 100 nice In the internal time period, nice value is the CPU time of the negative process (%) (nice/total) * 100 system In the internal time period, core time (%) (system/total) * 100iowait in the internal time period, hard disk IO waiting time (%) (iowait /total) * 100irq in the internal time period, hard interrupt time (%) (irq/total)*100soft In the internal time period, soft interrupt time (%) (softirq/total)*100idle In the internal time period, the CPU removes the idle time for free for any reason other than waiting for the disk IO operation ( %)(idle/total)*100intr/s The number of interrupts received by the CPU per second during the internal time period intr/total)*100

CPU total working time=total_cur=user+system+nice +idle+iowait+irq+softirqtotal_pre=pre_user+ pre_system+ pre_nice+ pre_idle+ Pre_iowait+ pre_irq+ pre_softirquser=user_cur – user_pretotal=total_cur-total_pre where _cur represents the current value and _pre represents the value before the interval time. All values ​​in the above table can take two decimal places.

Copyright © Windows knowledge All Rights Reserved