工作多年后,不能只满足于程序功能的正常性,还需要经常分析性能问题。
最近查一个线上问题,用到了vmstat, 也顺便来介绍下iostat
直接man命令来看看:
ubuntu@VM-0-15-ubuntu:~$ man vmstat
VMSTAT(8) System Administration VMSTAT(8)
NAME
vmstat - Report virtual memory statistics
SYNOPSIS
vmstat [options] [delay [count]]
DESCRIPTION
vmstat reports information about processes, memory, paging, block IO, traps, disks and
cpu activity.
The first report produced gives averages since the last reboot. Additional reports
give information on a sampling period of length delay. The process and memory reports
are instantaneous in either case.
OPTIONS
delay The delay between updates in seconds. If no delay is specified, only one
report is printed with the average values since boot.
可以看到, vmstat命令可以输出进程、内存、分页、IO等诸多信息。挺有用。
接下来,我们看看iostat:
ubuntu@VM-0-15-ubuntu:~$ man iostat
IOSTAT(1) Linux User's Manual IOSTAT(1)
NAME
iostat - Report Central Processing Unit (CPU) statistics and input/output statistics
for devices and partitions.
SYNOPSIS
iostat [ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ] [ -j
{ ID | LABEL | PATH | UUID | ... } ] [ [ -H ] -g group_name ] [ -p [ device [,...] |
ALL ] ] [ device [...] | ALL ] [ interval [ count ] ]
DESCRIPTION
The iostat command is used for monitoring system input/output device loading by
observing the time the devices are active in relation to their average transfer rates.
The iostat command generates reports that can be used to change system configuration
to better balance the input/output load between physical disks.
The first report generated by the iostat command provides statistics concerning the
time since the system was booted, unless the -y option is used (in this case, this
first report is omitted). Each subsequent report covers the time since the previous
report. All statistics are reported each time the iostat command is run.
iostat主要是输出CPU统计信息和IO信息的。
根据我的实际经验来看, vmstat的使用频率远高于iostat.
在实际开发中,要熟练掌握这些命令的使用。实际上,在一些笔试和面试中也会遇到此类问题,如果不知道的话,真的很容易歇菜。
扫描二维码关注公众号,回复:
13306371 查看本文章
