环境:
[Oracle@ www shell]$ uname -a
Linux simpleit.domain.cn 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 athlon i386 GNU/Linux
[oracle@ www shell]$ cat /etc/RedHat-release
CentOS release 5.5 (Final)
使用iostat监控磁盘繁忙程度(使用率%util)
[oracle@ www shell]$ iostat -x
Linux 2.6.18-194.el5 (simpleit.domain.cn) 12/18/2011
avg-cpu: %user %nice %system %iowait %steal %idle
0.180.060.460.280.00 99.02
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.10 1.17 1.05 4.4838.45 129.5430.42 0.022.80 0.72 0.40
sda1 0.00 0.00 0.00 0.00 0.01 0.0024.72 0.003.64 3.24 0.00
sda2 0.08 1.15 0.11 0.62 4.9314.1826.30 0.005.29 1.26 0.09
sda3 0.01 0.00 0.00 0.00 0.01 0.0023.97 0.003.16 2.71 0.00
sda4 0.00 0.00 0.00 0.00 0.00 0.00 1.83 0.009.17 9.17 0.00
sda5 0.00 0.00 0.50 1.3316.9536.0529.08 0.002.00 1.24 0.23
sda6 0.00 0.01 0.21 0.60 8.1821.6236.55 0.002.89 1.94 0.16
sda7 0.00 0.01 0.18 1.70 6.3349.1929.50 0.002.39 1.15 0.22
sda8 0.00 0.00 0.05 0.22 2.05 8.4938.47 0.003.95 2.37 0.06
[oracle@ www shell]$ iostat -x 5 5
Linux 2.6.18-194.el5 (simpleit.domain.cn) 12/18/2011
avg-cpu: %user %nice %system %iowait %steal %idle
0.180.060.460.280.00 99.02
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.10 1.17 1.05 4.4838.45 129.5330.42 0.022.79 0.72 0.40
sda1 0.00 0.00 0.00 0.00 0.01 0.0024.72 0.003.64 3.24 0.00
sda2 0.08 1.15 0.11 0.62 4.9314.1826.30 0.005.29 1.26 0.09
sda3 0.01 0.00 0.00 0.00 0.01 0.0023.97 0.003.16 2.71 0.00
sda4 0.00 0.00 0.00 0.00 0.00 0.00 1.83 0.009.17 9.17 0.00
sda5 0.00 0.00 0.50 1.3316.9436.0529.08 0.002.00 1.24 0.23
sda6 0.00 0.01 0.21 0.60 8.1821.6236.55 0.002.89 1.94 0.16
sda7 0.00 0.01 0.18 1.70 6.3349.1929.50 0.002.39 1.15 0.22
sda8 0.00 0.00 0.05 0.22 2.05 8.4938.47 0.003.95 2.37 0.06
avg-cpu: %user %nice %system %iowait %steal %idle
0.000.000.580.290.00 99.13
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 2.91 9.88 10.47 289.24 316.2829.76 0.010.63 0.19 0.38
sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda2 0.00 2.91 0.00 0.58 0.0027.9148.00 0.000.50 0.50 0.03
sda3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda5 0.00 0.00 5.81 3.20 186.0588.3730.45 0.000.42 0.29 0.26
sda6 0.00 0.00 1.16 1.7437.2155.8132.00 0.000.80 0.80 0.23
sda7 0.00 0.00 2.03 3.2038.0888.3724.17 0.000.78 0.33 0.17
sda8 0.00 0.00 0.87 1.7427.9155.8132.00 0.000.89 0.44 0.12
avg-cpu: %user %nice %system %iowait %steal %idle
0.000.000.000.000.00 100.00
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.87 0.00 3.49 0.0076.7422.00 0.000.83 0.25 0.09
sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda2 0.00 0.87 0.00 1.16 0.0016.2814.00 0.000.25 0.25 0.03
sda3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda5 0.00 0.00 0.00 0.87 0.0020.9324.00 0.001.00 0.67 0.06
sda6 0.00 0.00 0.00 0.29 0.00 9.3032.00 0.001.00 1.00 0.03
sda7 0.00 0.00 0.00 1.16 0.0030.2326.00 0.001.25 0.50 0.06
sda8 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
avg-cpu: %user %nice %system %iowait %steal %idle
0.000.000.290.000.00 99.71
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 0.00 2.32 0.0060.2926.00 0.001.00 0.38 0.09
sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda5 0.00 0.00 0.00 0.87 0.0020.8724.00 0.001.00 1.00 0.09
sda6 0.00 0.00 0.00 0.29 0.00 9.2832.00 0.001.00 1.00 0.03
sda7 0.00 0.00 0.00 1.16 0.0030.1426.00 0.001.00 0.50 0.06
sda8 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
avg-cpu: %user %nice %system %iowait %steal %idle
0.000.000.000.000.00 100.00
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 0.00 2.32 0.0060.2926.00 0.001.00 0.25 0.06
sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
sda5 0.00 0.00 0.00 0.87 0.0020.8724.00 0.001.00 0.67 0.06
sda6 0.00 0.00 0.00 0.29 0.00 9.2832.00 0.001.00 1.00 0.03
sda7 0.00 0.00 0.00 1.16 0.0030.1426.00 0.001.00 0.50 0.06
sda8 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.000.00 0.00 0.00
一个小脚本:
##disk_busy.sh ##
## created by Laughing ##
#!/bin/bash
iostat -x | awk '/^Device:/'
iostat -x 5 5 | grep -v 'avg-cpu:' | grep -v '^ ' | grep -v '^Device:' |
awk '{ print $12 ", " $0}' $* | ##取第12个参数值放到第一位,即xxx,空格 这种形式
sort -n | ##以数字排序
awk -F ',' '{print $2 }' | ##以,分隔,打印第二个参数值
tail -10
[oracle@ www shell]$ ./disk_busy.sh
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda5 0.00 0.00 0.00 1.75 0.0023.1013.17 0.000.83 0.67 0.12
sda 0.00 0.58 0.00 4.68 0.0074.2715.88 0.000.75 0.31 0.15
sda6 0.00 0.01 0.21 0.60 8.1721.6236.54 0.002.89 1.94 0.16
sda7 0.00 0.01 0.18 1.70 6.3349.1929.50 0.002.39 1.15 0.22
sda5 0.00 0.00 0.50 1.3316.9436.0529.08 0.002.00 1.24 0.23
sda 0.10 1.17 1.05 4.4838.44 129.5330.42 0.022.79 0.72 0.40
sda6 0.00 0.00 0.00 0.29 0.00 9.2832.00 0.01 27.00 27.00 0.78
sda7 0.00 0.00 0.00 1.16 0.0030.1426.00 0.02 21.00 7.00 0.81
sda5 0.00 0.00 0.00 0.87 0.0020.8724.00 0.02 19.00 9.67 0.84
sda 0.00 0.00 0.00 2.61 0.0062.6124.00 0.05 19.00 3.56 0.93