Common Linux system performance monitoring commands and linux system performance monitoring

Source: Internet
Author: User

Common Linux system performance monitoring commands and linux system performance monitoring

URL: http://www.cnblogs.com/myresearch/p/linux-monitor-tools.html.

Monitor CPU usage

Run the following command:

[root@localhost ~]# gnome-system-monitor

The graphical tool GNOME System Monitor is displayed, as shown in:

Monitor CPU scheduler program running queues

You can use the vmstat command in linux.

Vmstat is short for Virtual Meomory Statistics (Virtual Memory Statistics) and is a real-time system monitoring tool. This command uses the knlist subroutine and the/dev/kmen pseudo device drive to access the data, and the output information is printed directly on the screen. CPU-related information provided by vmstat includes:
(1) How many tasks are running
(2) CPU usage
(3) CPU interruption
(4) Number of context switches

The following describes only the CPU-related parameters of Vmstat.

The syntax of vmstat is as follows:

Vmstat [delay [count]

The parameters are described as follows:

Parameters Explanation
Delay Interval between two adjacent Samples
Count The number of samples. count can only be used with delay.

If no parameter exists, vmstat displays the average value of all information after the system is started. The average information of the first line since the system was started when delay exists. From the second line, the output is the average information of the previous delay period. When the system has multiple CPUs, the output is the average value of all CPUs.

Parameters Explanation Obtain data from/proc/stat
R The number of tasks waiting for CPU in the queue during the internal period, that is, the number of tasks that do not contain the vmstat process. Procs_running-1
B During the internal period, the number of tasks blocked by resources (I/0, page scheduling, etc.) is usually close to 0. Procs_blocked
Us User-mode CPU time (%) in internal time period, including nice value as negative Process (User + nice)/total * 100
Sy CPU time in the core State (%) during the internal Period) (System + irq + softirq)/total * 100
Id Cpu idle time in the internal period, excluding the time (%) waiting for I/o) Idle/total * 100
Wa I/o wait time (%) during the internal Period) Iowait/total * 100
In Number of interruptions per second during the internal Period Intr/interval
Cs The number of context switches per second during the internal period, that is, the number of kernel task exchanges per second. Ctxt/interval

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

Total = total_cur-total_pre

[root@localhost ~]# vmstat

The running result is as follows:

Monitoring lock Competition

Use the pidstat command in the sysstat package to monitor

[root@localhost ~]# pidstat

The running result is as follows:

Linux 2.6.32-431. el6.x86 _ 64 (localhost. localdomain) 05/07/15 _ x86_64 _ (1 CPU)

09:58:18 PID % usr % system % guest % CPU Command
09:58:18 1 0.00 0.00 0.00 0.00 0 init
09:58:18 4 0.00 0.00 0.00 0.00 0 ksoftirqd/0

......

09:58:18 37143 0.00 0.00 0.00 0 ready-launch
09:58:18 37144 0.00 0.00 0.00 0 running-daemon
09:58:18 37268 0.00 0.00 0.00 0 fprintd
09:58:18 37272 0.00 0.00 0.00 0 pidstat

Monitor network I/O usage

Nicstat was originally used to display network card traffic on the Solaris platform. Tim Cook transplanted it to the linux platform.

First install it. The source code is here. The version used here is 1.92.

Install the make environment:

yum install gcc gcc-c++ make automake autoconf -y

Because nicstat depends on 32 bit glibc package

yum install libgcc.i686 glibc.i686 glibc-devel.i686  -y

Download and install the file:

# wget -c http://nchc.dl.sourceforge.net/project/nicstat/nicstat-1.92.tar.gz# tar zxvf nicstat-1.92.tar.gz# cd nicstat-1.92# cp Makefile.Linux Makefile# uname -m

[Root @ localhost nicstat-1.92] # make
Gcc-O3-m32 nicstat. c-o nicstat
Nicstat. c: 99: 1: warning: "DUPLEX_UNKNOWN" redefined
In file encoded ded from nicstat. c: 84:
/Usr/include/linux/ethtool. h: 691: 1: warning: this is the location of the previous definition
Mv nicstat './nicstat. sh -- bin-name'

[root@localhost nicstat-1.92]# ./nicstat.sh

Disk I/O usage

Iostat [-t] [-c] [interval [count]

The parameters are described as follows:

Parameters Explanation
T Time used for output
C Indicates that only CPU information is displayed.
Internal Interval between two adjacent Samples
Count The number of samples. count can only be used with delay.

If no parameter exists, iostat displays the average value of all information after the system is started. CPU-related output

Parameters Explanation Obtained from/proc/stat
CPU Processor ID
User User-mode CPU time (%) during the internal period, excluding the nice value as a negative Process Usr/total * 100
Nice During the internal period, the nice value is the CPU time of the negative process (%) Nice/total * 100
Sys Core time in internal period (%) (System + irq + softirq)/total * 100
Iowait Hard Disk IO wait time (%) during internal Period) Iowait/total * 100
Idle In the internal period, the idle time (%) of the CPU except for the disk I/O operation for any reason) Idle/total * 100

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

Total = total_cur-total_pre

The average information of the first line since the system was started when interval exists. From the second line, the output is the average information of the previous interval period.

Use iostat command

[root@localhost ~]# iostat

The running result is as follows:

Linux 2.6.32-431. el6.x86 _ 64 (localhost. localdomain) 05/07/15 _ x86_64 _ (1 CPU)

Avg-cpu: % user % nice % system % iowait % steal % idle
6.12 0.00 1.35 2.35 0.00 90.19

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Sda 6.03 267.11 272.53 26904430 27450404

PS: I have shared many Linux performance-related resources on my Brendan Gregg personal site:

Linux observability tools | Linux Performance Observation Tool

Linux benchmarking tools | Linux Performance Evaluation Tool

Linux tuning tools | Linux Performance tuning Tool

Linux observability sar

More charts and presentations, please move on: http://www.brendangregg.com/linuxperf.html

Add: Last year I shared a speech on Brendan Gregg at the SCaLE 11x conference, "Linux Performance Analysis and Tools | Linux Performance Analysis and Tools", with a video (Youtube) in the link to the https://www.joyent.com/blog/linux-performance-analysis-and-tools-brendan-gregg-s-talk-at-scale-11x) and SlideShare, so please bring your own ladder to access.

References

Http://www.cnblogs.com/argb/p/3448661.html

Http://blog.jobbole.com/76103/

Http://blog.yufeng.info/archives/2518

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.