In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
The main content of this article is "how to monitor the performance of Linux in detail". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to monitor the performance of Linux in detail.
This is part of our ongoing series of Linux commands and performance monitoring. Both the vmstat and iostat commands apply to all major unix-like systems (Linux/unix/FreeBSD/Solaris).
If the vmstat and iostat commands are not available on your system, install the sysstat package. The vmstat,sar and iostat commands are included in the sysstat (system Monitoring tool) package. The iostat command generates statistics for CPU and all devices. You can download the source code package to compile and install sysstat from this connection, but we recommend that you install it through the YUM command.
Install sysstat on a Linux system
The code is as follows:
# yum-y install sysstat
Vmstat-brief information about memory, processes, paging, etc.
Iostat-CPU statistics, input / output statistics for devices and partitions.
Six examples of vmstat commands under Linux
1. List active and inactive memory
Output six columns in the following example. The meaning of each column parsed in the man page of vmstat. The most important are the free properties in memory and the si and so properties in the swap partition.
The code is as follows:
[root@tecmint] # vmstat-a
Procs-memory--swap---io-----system---cpu-
R b swpd free inact active si so bi bo in cs us sy id wa st
10 0 810420 97380 70628 0 0 115 4 89 79 1 6 90 3 0
Free-Free memory space
Si-the amount of data swapped into memory from disk (in KB) per second.
So-the amount of data, in KB, swapped out of memory per second.
Note: if you execute the vmstat command without arguments, it will output a summary report since the system was started.
two。 Execute vmstat every X seconds for N times
The following command will execute vmstat every 2 seconds, and then automatically stop execution after 6 times.
The code is as follows:
[root@tecmint ~] # vmstat 2 6
Procs-memory--swap---io-----system---cpu-
R b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 810420 22064 101368 0 0 56 3 50 57 0 3 95 20
00 0 810412 22064 101368 00 00 16 35 00 100 00
00 0 810412 22064 101368 00 00 14 35 00 100 00
00 0 810412 22064 101368 00 00 17 38 00 100 00
00 0 810412 22064 101368 00 00 17 35 00 100 00
00 0 810412 22064 101368 00 00 18 36 01 100 00
3. Vmstat command with timestamp
Execute the vmstat command with the-t argument, which will be followed by a timestamp on each line of output, as shown below.
The code is as follows:
[tecmint@tecmint] $vmstat-t 1 5
Procs-memory- swap---io---- system---cpu- timestamp
R b swpd free buff cache si so bi bo in cs us sy id wa st
0 632028 24992 192244 0 0 70 5 55 78 1 3 95 1 0 2012-09-02 14:57:18 IST
1 0 632028 24992 192244 0 000 171 514 1 594 0 2012-09-02 14:57:19 IST
1 00 631904 24992 192244 00 00 195 600 0 5 95 00 2012-09-02 14:57:20 IST
0 631780 24992 192244 0 000 156 524 0 5 95 00 2012-09-02 14:57:21 IST
1 0 631656 24992 192244 000 0 189 5920 5 95 631656 2012-09-02 14:57:22 IST
4. Count all kinds of counters
The-s argument of the vmstat command outputs statistics for various event counters and memory.
The code is as follows:
[tecmint@tecmint] $vmstat-s
1030800 total memory
524656 used memory
277784 active memory
185920 inactive memory
506144 free memory
26864 buffer memory
310104 swap cache
2064376 total swap
0 used swap
2064376 free swap
4539 non-nice user cpu ticks
0 nice user cpu ticks
11569 system cpu ticks
329608 idle cpu ticks
5012 IO-wait cpu ticks
79 IRQ cpu ticks
74 softirq cpu ticks
0 stolen cpu ticks
336038 pages paged in
67945 pages paged out
0 pages swapped in
0 pages swapped out
258526 interrupts
392439 CPU context switches
1346574857 boot time
2309 forks
5. Disk statistics
The-d parameter of vmstat will output statistics for all disks.
The code is as follows:
[tecmint@tecmint] $vmstat-d
Disk--reads--writes--IO-
Total merged sectors ms total merged sectors ms cur sec
Ram0 0 0 0
Ram1 0 0 0
Ram2 0 0 0
Ram3 0 0 0
Ram4 0 0 0
Ram5 0 0 0
Ram6 0 0 0
Ram7 0 0 0
Ram8 0 0 0
Ram9 0 0 0
Ram10 0 0 0
Ram11 0 0 0
Ram12 0 0 0
Ram13 0 0 0
Ram14 0 0 0
Ram15 0 0 0
Loop0 0 0 0
Loop1 0 0 0
Loop2 0 0 0
Loop3 0 0 0
Loop4 0 0 0
Loop5 0 0 0
Loop6 0 0 0
Loop7 0 0 0
Sr0 0 0 0
Sda 7712 5145 668732 409619 3282 28884 257402 644566 0 126
Dm-0 11578 0 659242 1113017 32163 0 257384 8460026 0 126
Dm-1 324 0 2592 3845 0 0 0 2
6. Output statistics in units of MB
The-S and-M parameters (uppercase and MB) of vmstat will be output in MB. Vmstat outputs statistics in units of KB by default.
The code is as follows:
[root@tecmint] # vmstat-S M 1 5
Procs-memory--swap---io-----system---cpu-
R b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 346 53 476 0 0 95 8 42 55 0 2 96 2 0
00 0 346 53 476 00 00 12 15 00 100 00
00 0 346 53 476 00 00 32 62 00 100 00
00 0 346 53 476 00 00 15 13 00 100 00
0 0 0 346 53 476 0 0 0 34 61 0 1 99 0 0
Six examples of Iostat commands under linux
1. Output CPU and input / output statistics
The iostat command with no parameters will output CPU and output / output statistics for each partition, as shown below.
The code is as follows:
[root@tecmint ~] # iostat
Linux 2.6.32-279.el6.i686 (tecmint.com) 09max 03max 2012 _ i6861CPU)
Avg-cpu:% user nice% system% iowait% steal% idle
0.12 0.01 1.54 2.08 0.00 96.24
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Sda 3.59 161.02 13.48 1086002 90882
Dm-0 5.76 159.71 13.47 1077154 90864
Dm-1 0.05 0.38 0.00 2576 0
two。 Only output statistics for CPU
The-c argument of the iostat command outputs only the statistics for CPU, as shown below.
The code is as follows:
[root@tecmint] # iostat-c
Linux 2.6.32-279.el6.i686 (tecmint.com) 09max 03max 2012 _ i6861CPU)
Avg-cpu:% user nice% system% iowait% steal% idle
0.12 0.01 1.47 1.98 0.00 96.42
3. Output only disk input / output statistics
The-d parameter of the iostat command outputs only the input / output statistics for all partitions of the disk, as shown below.
The code is as follows:
[root@tecmint ~] # iostat-d
Linux 2.6.32-279.el6.i686 (tecmint.com) 09max 03max 2012 _ i6861CPU)
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Sda 3.35 149.81 12.66 1086002 91746
Dm-0 5.37 148.59 12.65 1077154 91728
Dm-1 0.04 0.36 0.00 2576 0
4. Output only the input / output statistics of a disk
By default, the iostat command outputs statistics for all partitions, but if you add the-p parameter and disk device name to the iostat command, the command will output only the input / output statistics for the listed disks, as shown below.
The code is as follows:
[root@tecmint] # iostat-p sda
Linux 2.6.32-279.el6.i686 (tecmint.com) 09max 03max 2012 _ i6861CPU)
Avg-cpu:% user nice% system% iowait% steal% idle
0.11 0.01 1.44 1.92 0.00 96.52
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Sda 3.32 148.52 12.55 1086002 91770
Sda1 0.07 0.56 0.00 4120 18
Sda2 3.22 147.79 12.55 1080650 91752
5. Output Statistics for logical Volume Management (LVM)
The-N (uppercase) parameter of the iostat command outputs LVM statistics, as shown below. LVM is a mechanism for managing disk partitions in the linux environment, which is a logical layer between disk partitions and the file system.
The code is as follows:
[root@tecmint] # iostat-N
Linux 2.6.32-279.el6.i686 (tecmint.com) 09max 03max 2012 _ i6861CPU)
Avg-cpu:% user nice% system% iowait% steal% idle
0.11 0.01 1.39 1.85 0.00 96.64
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Sda 3.20 142.84 12.16 1086002 92466
Vg_tecmint-lv_root 5.13 141.68 12.16 1077154 92448
Vg_tecmint-lv_swap 0.04 0.34 0.00 2576 0
6. Iostat version information
The-V (uppercase) parameter of iostat will output the version information of iostat, as shown below.
The code is as follows:
[root@tecmint] # iostat-V
Sysstat version 9.0.4
(C) Sebastien Godard (sysstat orange.fr)
At this point, I believe you have a deeper understanding of "how to monitor the performance of Linux in detail". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.