首页 > 其他 > 详细

【工具】cpu监控利器

时间:2015-05-26 02:19:43      阅读:229      评论:0      收藏:0      [点我收藏+]
一 介绍
    最近在做cgroup方面的压测,使用到cpu的监控工具--mpstat。mpstat是Multiprocessor Statistics的缩写,是实时系统监控工具。其报告与CPU的一些统计信息,这些信息存放在/proc/stat文件中。在多CPUs系统里,其不但能查看所有CPU的平均状况信息,而且能够查看特定CPU的信息。mpstat最大的特点是:可以查看多核心cpu中每个计算核心的统计数据;而类似工具vmstat只能查看系统整体cpu情况。

二 用法
   mpstat [-P {|ALL}] [internal [count]]
   参数解释
   -P {|ALL} 表示监控哪个CPU, cpu在[0,cpu个数-1]中取值,比如要查看编号 8,15的cpu 则执行 mpstat -P 8,15 
   internal 相邻的两次采样的间隔时间、
   count 采样的次数,count只能和delay一起使用
当没有参数时,mpstat则显示系统启动以后所有信息的平均值。有interval时,第一行的信息自系统启动以来的平均信息。从第二行开始,输出为前一个interval时间段的平均信息。

三 用例
查看 编号为8 15 20 的cpu运行情况:

  1. $mpstat -P 8,15,20
  2. Linux 2.6.32-220.23.2.ali878.el6.x86_64 (g1-myb080005.et2) 05/24/2015 _x86_64_ (32 CPU)
  3. 04:00:23 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
  4. 04:00:23 PM 8  2.08 0.01 5.74 0.06 0.00 0.25 0.00 0.00 91.86
  5. 04:00:23 PM 15 0.56 0.00 0.13 0.04 0.00 0.10 0.00 0.00 99.16
  6. 04:00:23 PM 20 0.80 0.00 0.91 0.06 0.00 0.12 0.00 0.00 98.11

如果要看每个cpu核心的详细当前运行状况信息,输出如下:

  1. $mpstat -P ALL 1 ##每隔一秒查看cpu的运行情况。
  2. Linux 2.6.32-220.23.2.ali878.el6.x86_64 (g1-myb080005.et2) 05/24/2015 _x86_64_ (32 CPU)
  3. 04:01:34 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
  4. 04:01:35 PM all 0.06 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.94
  5. 04:01:35 PM 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  6. 04:01:35 PM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  7. 04:01:35 PM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  8. 04:01:35 PM 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  9. 04:01:35 PM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  10. 04:01:35 PM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  11. 04:01:35 PM 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  12. 04:01:35 PM 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  13. 04:01:35 PM 8 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  14. 04:01:35 PM 9 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  15. 04:01:35 PM 10 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  16. 04:01:35 PM 11 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  17. 04:01:35 PM 12 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  18. 04:01:35 PM 13 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  19. 04:01:35 PM 14 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  20. 04:01:35 PM 15 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  21. 04:01:35 PM 16 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  22. 04:01:35 PM 17 0.00 0.00 0.99 0.00 0.00 0.00 0.00 0.00 99.01
  23. 04:01:35 PM 18 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  24. 04:01:35 PM 19 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  25. 04:01:35 PM 20 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  26. 04:01:35 PM 21 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  27. 04:01:35 PM 22 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  28. 04:01:35 PM 23 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  29. 04:01:35 PM 24 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  30. 04:01:35 PM 25 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  31. 04:01:35 PM 26 0.99 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.01
  32. 04:01:35 PM 27 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  33. 04:01:35 PM 28 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  34. 04:01:35 PM 29 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
  35. 04:01:35 PM 30 0.99 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.01
  36. 04:01:35 PM 31 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.0
字段的含义如下:
  
  1. %user   在internal时间段里,用户态的CPU时间(%),不包含nice值为负进程 (usr/total)*100
  2. %nice   在internal时间段里,nice值为负进程的CPU时间(%) (nice/total)*100
  3. %sys    在internal时间段里,内核时间(%) (system/total)*100
  4. %iowait 在internal时间段里,硬盘IO等待时间(%) (iowait/total)*100
  5. %irq    在internal时间段里,硬中断时间(%) (irq/total)*100
  6. %soft   在internal时间段里,软中断时间(%) (softirq/total)*100
  7. %idle   在internal时间段里,CPU除去等待磁盘IO操作外的因为任何原因而空闲的时间闲置时间(%) (idle/total)*100




【工具】cpu监控利器

原文:http://blog.itpub.net/22664653/viewspace-1669580/

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!