Introduction to Linux CPU Real-time Monitoring command mpstat, linuxmpstat

Source: Internet
Author: User

Introduction to Linux CPU Real-time Monitoring command mpstat, linuxmpstat

1. Introduction
Mpstat is short for Multiprocessor Statistics and is a real-time system monitoring tool. The report contains some CPU statistics, which are stored in the/proc/stat file. In a multi-CPUs system, it can not only view the average status information of all CPUs, but also view information about specific CPUs. The biggest feature of mpstat is that you can view statistics of each computing core in multiple cpu cores. A tool similar to vmstat can only view the overall cpu usage 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 37017186
Preparing... ######################################## ### [100%]
1: sysstat ####################################### #### [100%]

3. Instance
Usage
Mpstat-V displays the mpstat version
Mpstat-p all displays all cpu Information
Mpstat-P n displays information about the nth cup. n is a number and the count starts from 0.
Mpstat n m: cpu information is displayed once every n seconds, m is displayed continuously, and an average value is displayed at last.
Mpstat n displays cpu information once every n seconds.
 
View the detailed current running status of each cpu core. The output is as follows:
[Root @ ora10g ~] # Mpstat-P ALL
Linux 2.6.18-194. el5 (ora10g.up.com) 11/05/14
09:13:02 CPU % user % nice % sys % iowait % irq % soft % steal % idle intr/s
09:13:02 all 0.62 0.01 0.54 3.48 0.00 0.02 0.00 95.32 1039.58
09:13:02 0 0.92 0.01 1.18 8.77 0.01 0.05 0.00 89.06 1030.23
09: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.74
09:13:02 15 0.18 0.00 0.22 0.70 0.00 0.01 0.00 98.90 0.59

View the current running status of a multi-core CPU core, which is updated every 2 seconds.
[Root @ ora10g ~] # Mpstat-p all 2

View the usage of a cpu. The value ranges from 0 to 1.
[Root @ ora10g ~] # Mpstat-P 2
Linux 2.6.18-194. el5 (ora10g.up.com) 11/05/14
10:19:28 CPU % user % nice % sys % iowait % irq % soft % steal % idle intr/s
10: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 a multi-core CPU core, which is updated every 2 seconds and displays 5
[Root @ ora10g ~] # Mpstat-p all 2 5

4. Field meanings:
Explanation:
CPU: Processor number. 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) is
One 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 outstanding disk I/O request.
Intr/s: Show the total number of interrupts provisioned ed per second by the CPU or CPUs.

Get data from/proc/stat
CPU processor ID
User-state CPU time (%) during internal, excluding the nice value as negative process (usr/total) * 100
Nice in the internal period, nice value is the CPU time of the negative process (%) (nice/total) * 100
System Core time (%) (system/total) * 100 during the internal Period
Hard Disk I/O wait time (%) (iowait/total) * 100 during the internal Period
Hard interrupt time (%) (irq/total) * 100 during the internal Period
Soft Interrupt time (%) (softirq/total) * 100 during the internal Period
Idle time (%) (idle/total) in addition to waiting for disk I/O operations during the internal period x 100
Intr/s: the number of interruptions received by the CPU per second in the internal period. intr/total) * 100

Total CPU time = total_cur = user + system + nice + idle + iowait + irq + softirq
Total_pre = pre_user + pre_system + pre_nice + pre_idle + pre_iowait + pre_irq + pre_softirq
User = user_cur-user_pre
Total = total_cur-total_pre
_ Cur indicates the current value, and _ pre indicates the value before the interval time. All values in the preceding table can be two decimal places.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.