当前位置: 移动技术网 > 科技>操作系统>Linux > Linux系统中Sysstat性能监控工具包中20个实用命令

Linux系统中Sysstat性能监控工具包中20个实用命令

2018年11月08日  | 移动技术网科技  | 我要评论

  今天,我们将会通过一些有趣的实例来学习mpstat, pidstat, iostat和sar等工具,这些工具可以帮组我们找出系统中的问题。这些工具都包含了不同的选项,这意味着你可以根据不同的工作使用不同的选项,或者根据你的需求来自定义脚本。我们都知道,系统管理员都会有点懒,他们经常去寻找一些更简单的方法来完成他们的工作。

  mpstat - 处理器统计信息

  1.不带任何参数的使用mpstat命令将会输出所有cpu的平均统计信息


复制代码
代码如下:
tecmint@tecmint ~ $ mpstat

linux 3.11.0-23-generic (tecmint.com) thursday 04 september 2014 _i686_ (2 cpu)

12:23:57 ist cpu %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
12:23:57 ist all 37.35 0.01 4.72 2.96 0.00 0.07 0.00 0.00 0.00 54.88

  2.使用‘-p’ (处理器编号)和‘all’参数将会从0开始独立的输出每个cpu的统计信息,0表示第一个cpu。


复制代码
代码如下:
tecmint@tecmint ~ $ mpstat -p all

linux 3.11.0-23-generic (tecmint.com) thursday 04 september 2014 _i686_ (2 cpu)

12:29:26 ist cpu %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
12:29:26 ist all 37.33 0.01 4.57 2.58 0.00 0.07 0.00 0.00 0.00 55.44
12:29:26 ist 0 37.90 0.01 4.96 2.62 0.00 0.03 0.00 0.00 0.00 54.48
12:29:26 ist 1 36.75 0.01 4.19 2.54 0.00 0.11 0.00 0.00 0.00 56.40

  3.要进行‘n’次,平均每次间隔n秒的输出cpu统计信息,如下所示。


复制代码
代码如下:
tecmint@tecmint ~ $ mpstat -p all 2 5

linux 3.11.0-23-generic (tecmint.com) thursday 04 september 2014 _i686_ (2 cpu)

12:36:21 ist cpu %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
12:36:23 ist all 53.38 0.00 2.26 0.00 0.00 0.00 0.00 0.00 0.00 44.36
12:36:23 ist 0 46.23 0.00 1.51 0.00 0.00 0.00 0.00 0.00 0.00 52.26
12:36:23 ist 1 60.80 0.00 3.02 0.00 0.00 0.00 0.00 0.00 0.00 36.18

12:36:23 ist cpu %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
12:36:25 ist all 34.18 0.00 2.30 0.00 0.00 0.00 0.00 0.00 0.00 63.52
12:36:25 ist 0 31.63 0.00 1.53 0.00 0.00 0.00 0.00 0.00 0.00 66.84
12:36:25 ist 1 36.73 0.00 2.55 0.00 0.00 0.00 0.00 0.00 0.00 60.71

12:36:25 ist cpu %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
12:36:27 ist all 33.42 0.00 5.06 0.25 0.00 0.25 0.00 0.00 0.00 61.01
12:36:27 ist 0 34.34 0.00 4.04 0.00 0.00 0.00 0.00 0.00 0.00 61.62
12:36:27 ist 1 32.82 0.00 6.15 0.51 0.00 0.00 0.00 0.00 0.00 60.51

  (lctt译注: 上面命令中‘2’ 表示每2秒执行一次‘mpstat -p all’命令, ‘5’表示共执行5次)

  4.使用‘i’参数将会输出每个处理器的中断统计信息


复制代码
代码如下:
tecmint@tecmint ~ $ mpstat -i

linux 3.11.0-23-generic (tecmint.com) thursday 04 september 2014 _i686_ (2 cpu)

12:39:56 ist cpu intr/s
12:39:56 ist all 651.04

12:39:56 ist cpu 0/s 1/s 6/s 8/s 9/s 12/s 16/s 17/s 20/s 21/s 22/s 23/s 45/s 46/s 47/s nmi/s loc/s spu/s pmi/s iwi/s rtr/s res/s cal/s tlb/s trm/s thr/s mce/s mcp/s err/s mis/s
12:39:56 ist 0 76.27 1.73 0.00 0.00 0.42 0.33 0.00 0.06 11.46 0.00 0.00 0.01 7.62 1.87 0.05 0.33 182.26 0.00 0.33 3.03 0.00 22.66 0.16 5.14 0.00 0.00 0.00 0.00 0.00 0.00
12:39:56 ist 1 70.88 1.44 0.00 0.00 0.41 0.33 0.00 27.91 10.33 0.00 0.00 0.01 7.27 1.79 0.05 0.32 184.11 0.00 0.32 5.17 0.00 22.09 0.13 4.73 0.00 0.00 0.00 0.00 0.00 0.00

12:39:56 ist cpu hi/s timer/s net_tx/s net_rx/s block/s block_iopoll/s tasklet/s sched/s hrtimer/s rcu/s
12:39:56 ist 0 0.00 116.49 0.05 0.27 7.33 0.00 1.22 10.44 0.13 37.47
12:39:56 ist 1 0.00 111.65 0.05 0.41 7.07 0.00 56.36 9.97 0.13 41.38

  5.使用‘a’参数将会输出上面提到的所有信息,等同于‘-u -i all -p all’。


复制代码
代码如下:
tecmint@tecmint ~ $ mpstat -a

linux 3.11.0-23-generic (tecmint.com) thursday 04 september 2014 _i686_ (2 cpu)

12:41:39 ist cpu %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
12:41:39 ist all 38.70 0.01 4.47 2.01 0.00 0.06 0.00 0.00 0.00 54.76
12:41:39 ist 0 39.15 0.01 4.82 2.05 0.00 0.02 0.00 0.00 0.00 53.95
12:41:39 ist 1 38.24 0.01 4.12 1.98 0.00 0.09 0.00 0.00 0.00 55.57

12:41:39 ist cpu intr/s
12:41:39 ist all 651.73
12:41:39 ist 0 173.16
12:41:39 ist 1 225.89

12:41:39 ist cpu 0/s 1/s 6/s 8/s 9/s 12/s 16/s 17/s 20/s 21/s 22/s 23/s 45/s 46/s 47/s nmi/s loc/s spu/s pmi/s iwi/s rtr/s res/s cal/s tlb/s trm/s thr/s mce/s mcp/s err/s mis/s
12:41:39 ist 0 76.04 1.77 0.00 0.00 0.41 0.36 0.00 0.06 11.60 0.00 0.00 0.01 7.42 1.83 0.05 0.34 182.89 0.00 0.34 2.97 0.00 22.69 0.16 5.22 0.00 0.00 0.00 0.00 0.00 0.00
12:41:39 ist 1 70.70 1.48 0.00 0.00 0.40 0.36 0.00 27.47 10.46 0.00 0.00 0.01 7.08 1.75 0.05 0.32 184.83 0.00 0.32 5.10 0.00 22.19 0.13 4.91 0.00 0.00 0.00 0.00 0.00 0.00

12:41:39 ist cpu hi/s timer/s net_tx/s net_rx/s block/s block_iopoll/s tasklet/s sched/s hrtimer/s rcu/s
12:41:39 ist 0 0.00 116.96 0.05 0.26 7.12 0.00 1.24 10.42 0.12 36.99
12:41:39 ist 1 0.00 112.25 0.05 0.40 6.88 0.00 55.05 9.93 0.13 41.20

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网