免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1156 | 回复: 1
打印 上一主题 下一主题

linux iostat监控脚本 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-01-05 20:09 |只看该作者 |倒序浏览

linux iostat监控脚本







环境:





view plaincopy to clipboard
  1. 01.[oracle@simpleit shell]$ uname -a  
  2. 02.Linux simpleit.domain.cn 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 athlon i386 GNU/Linux  
  3. 03.[oracle@simpleit shell]$ cat /etc/redhat-release  
  4. 04.CentOS release 5.5 (Final)  
复制代码
使用iostat监控磁盘繁忙程度(使用率%util)




view plaincopy to clipboard
  1. 01.[oracle@simpleit shell]$ iostat -x  
  2. 02.Linux 2.6.18-194.el5 (simpleit.domain.cn)       12/18/2011  
  3. 03.  
  4. 04.avg-cpu:  %user   %nice %system %iowait  %steal   %idle  
  5. 05.           0.18    0.06    0.46    0.28    0.00   99.02  
  6. 06.  
  7. 07.Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util  
  8. 08.sda               0.10     1.17  1.05  4.48    38.45   129.54    30.42     0.02    2.80   0.72   0.40  
  9. 09.sda1              0.00     0.00  0.00  0.00     0.01     0.00    24.72     0.00    3.64   3.24   0.00  
  10. 10.sda2              0.08     1.15  0.11  0.62     4.93    14.18    26.30     0.00    5.29   1.26   0.09  
  11. 11.sda3              0.01     0.00  0.00  0.00     0.01     0.00    23.97     0.00    3.16   2.71   0.00  
  12. 12.sda4              0.00     0.00  0.00  0.00     0.00     0.00     1.83     0.00    9.17   9.17   0.00  
  13. 13.sda5              0.00     0.00  0.50  1.33    16.95    36.05    29.08     0.00    2.00   1.24   0.23  
  14. 14.sda6              0.00     0.01  0.21  0.60     8.18    21.62    36.55     0.00    2.89   1.94   0.16  
  15. 15.sda7              0.00     0.01  0.18  1.70     6.33    49.19    29.50     0.00    2.39   1.15   0.22  
  16. 16.sda8              0.00     0.00  0.05  0.22     2.05     8.49    38.47     0.00    3.95   2.37   0.06  
  17. 17.  
  18. 18.[oracle@simpleit shell]$ iostat -x 5 5  
  19. 19.Linux 2.6.18-194.el5 (simpleit.domain.cn)       12/18/2011  
  20. 20.  
  21. 21.avg-cpu:  %user   %nice %system %iowait  %steal   %idle  
  22. 22.           0.18    0.06    0.46    0.28    0.00   99.02  
  23. 23.  
  24. 24.Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util  
  25. 25.sda               0.10     1.17  1.05  4.48    38.45   129.53    30.42     0.02    2.79   0.72   0.40  
  26. 26.sda1              0.00     0.00  0.00  0.00     0.01     0.00    24.72     0.00    3.64   3.24   0.00  
  27. 27.sda2              0.08     1.15  0.11  0.62     4.93    14.18    26.30     0.00    5.29   1.26   0.09  
  28. 28.sda3              0.01     0.00  0.00  0.00     0.01     0.00    23.97     0.00    3.16   2.71   0.00  
  29. 29.sda4              0.00     0.00  0.00  0.00     0.00     0.00     1.83     0.00    9.17   9.17   0.00  
  30. 30.sda5              0.00     0.00  0.50  1.33    16.94    36.05    29.08     0.00    2.00   1.24   0.23  
  31. 31.sda6              0.00     0.01  0.21  0.60     8.18    21.62    36.55     0.00    2.89   1.94   0.16  
  32. 32.sda7              0.00     0.01  0.18  1.70     6.33    49.19    29.50     0.00    2.39   1.15   0.22  
  33. 33.sda8              0.00     0.00  0.05  0.22     2.05     8.49    38.47     0.00    3.95   2.37   0.06  
  34. 34.  
  35. 35.avg-cpu:  %user   %nice %system %iowait  %steal   %idle  
  36. 36.           0.00    0.00    0.58    0.29    0.00   99.13  
  37. 37.  
  38. 38.Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util  
  39. 39.sda               0.00     2.91  9.88 10.47   289.24   316.28    29.76     0.01    0.63   0.19   0.38  
  40. 40.sda1              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  41. 41.sda2              0.00     2.91  0.00  0.58     0.00    27.91    48.00     0.00    0.50   0.50   0.03  
  42. 42.sda3              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  43. 43.sda4              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  44. 44.sda5              0.00     0.00  5.81  3.20   186.05    88.37    30.45     0.00    0.42   0.29   0.26  
  45. 45.sda6              0.00     0.00  1.16  1.74    37.21    55.81    32.00     0.00    0.80   0.80   0.23  
  46. 46.sda7              0.00     0.00  2.03  3.20    38.08    88.37    24.17     0.00    0.78   0.33   0.17  
  47. 47.sda8              0.00     0.00  0.87  1.74    27.91    55.81    32.00     0.00    0.89   0.44   0.12  
  48. 48.  
  49. 49.avg-cpu:  %user   %nice %system %iowait  %steal   %idle  
  50. 50.           0.00    0.00    0.00    0.00    0.00  100.00  
  51. 51.  
  52. 52.Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util  
  53. 53.sda               0.00     0.87  0.00  3.49     0.00    76.74    22.00     0.00    0.83   0.25   0.09  
  54. 54.sda1              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  55. 55.sda2              0.00     0.87  0.00  1.16     0.00    16.28    14.00     0.00    0.25   0.25   0.03  
  56. 56.sda3              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  57. 57.sda4              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  58. 58.sda5              0.00     0.00  0.00  0.87     0.00    20.93    24.00     0.00    1.00   0.67   0.06  
  59. 59.sda6              0.00     0.00  0.00  0.29     0.00     9.30    32.00     0.00    1.00   1.00   0.03  
  60. 60.sda7              0.00     0.00  0.00  1.16     0.00    30.23    26.00     0.00    1.25   0.50   0.06  
  61. 61.sda8              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  62. 62.  
  63. 63.avg-cpu:  %user   %nice %system %iowait  %steal   %idle  
  64. 64.           0.00    0.00    0.29    0.00    0.00   99.71  
  65. 65.  
  66. 66.Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util  
  67. 67.sda               0.00     0.00  0.00  2.32     0.00    60.29    26.00     0.00    1.00   0.38   0.09  
  68. 68.sda1              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  69. 69.sda2              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  70. 70.sda3              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  71. 71.sda4              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  72. 72.sda5              0.00     0.00  0.00  0.87     0.00    20.87    24.00     0.00    1.00   1.00   0.09  
  73. 73.sda6              0.00     0.00  0.00  0.29     0.00     9.28    32.00     0.00    1.00   1.00   0.03  
  74. 74.sda7              0.00     0.00  0.00  1.16     0.00    30.14    26.00     0.00    1.00   0.50   0.06  
  75. 75.sda8              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  76. 76.  
  77. 77.avg-cpu:  %user   %nice %system %iowait  %steal   %idle  
  78. 78.           0.00    0.00    0.00    0.00    0.00  100.00  
  79. 79.  
  80. 80.Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util  
  81. 81.sda               0.00     0.00  0.00  2.32     0.00    60.29    26.00     0.00    1.00   0.25   0.06  
  82. 82.sda1              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  83. 83.sda2              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  84. 84.sda3              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  85. 85.sda4              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
  86. 86.sda5              0.00     0.00  0.00  0.87     0.00    20.87    24.00     0.00    1.00   0.67   0.06  
  87. 87.sda6              0.00     0.00  0.00  0.29     0.00     9.28    32.00     0.00    1.00   1.00   0.03  
  88. 88.sda7              0.00     0.00  0.00  1.16     0.00    30.14    26.00     0.00    1.00   0.50   0.06  
  89. 89.sda8              0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00  
复制代码
一个小脚本:




view plaincopy to clipboard
  1. 01.####################################################################  
  2. 02.##    disk_busy.sh       ##  
  3. 03.## created by Laughing   ##  
  4. 04.##    2012-01-04         ##  
  5. 05.####################################################################  
  6. 06.#!/bin/bash  
  7. 07.  
  8. 08.iostat -x | awk '/^Device:/'  
  9. 09.iostat -x 5 5 | grep -v 'avg-cpu:' | grep -v '^ ' | grep -v '^Device:' |   
  10. 10.awk '{ print $12 ", " $0}' $* | ##取第12个参数值放到第一位,即xxx,空格 这种形式  
  11. 11.sort -n |                       ##以数字排序  
  12. 12.awk -F ',' '{print $2 }' |      ##以,分隔,打印第二个参数值  
  13. 13.tail -10  
复制代码
view plaincopy to clipboard
  1. 01.[oracle@simpleit shell]$ ./disk_busy.sh  
  2. 02.Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util  
  3. 03. sda5              0.00     0.00  0.00  1.75     0.00    23.10    13.17     0.00    0.83   0.67   0.12  
  4. 04. sda               0.00     0.58  0.00  4.68     0.00    74.27    15.88     0.00    0.75   0.31   0.15  
  5. 05. sda6              0.00     0.01  0.21  0.60     8.17    21.62    36.54     0.00    2.89   1.94   0.16  
  6. 06. sda7              0.00     0.01  0.18  1.70     6.33    49.19    29.50     0.00    2.39   1.15   0.22  
  7. 07. sda5              0.00     0.00  0.50  1.33    16.94    36.05    29.08     0.00    2.00   1.24   0.23  
  8. 08. sda               0.10     1.17  1.05  4.48    38.44   129.53    30.42     0.02    2.79   0.72   0.40  
  9. 09. sda6              0.00     0.00  0.00  0.29     0.00     9.28    32.00     0.01   27.00  27.00   0.78  
  10. 10. sda7              0.00     0.00  0.00  1.16     0.00    30.14    26.00     0.02   21.00   7.00   0.81  
  11. 11. sda5              0.00     0.00  0.00  0.87     0.00    20.87    24.00     0.02   19.00   9.67   0.84  
  12. 12. sda               0.00     0.00  0.00  2.61     0.00    62.61    24.00     0.05   19.00   3.56   0.93  
复制代码

论坛徽章:
0
2 [报告]
发表于 2012-01-05 20:13 |只看该作者
谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP