一,mpstat的用途

mpstat是 Multiprocessor Statistics的缩写,是实时cpu监控工具。

在多CPU系统里,其不但能查看所有CPU的平均状况信息,而且能够查看特定CPU的信息

它的数据来自于 /proc/stat文件

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

对应的源码可以访问这里获取: https://github.com/liuhongdi/

说明:作者:刘宏缔 邮箱: 371125307@qq.com

二,mpstat所属的rpm包与安装

1,查看所属的包

[root@blog ~]# whereis mpstat
mpstat: /usr/bin/mpstat /usr/share/man/man1/mpstat.1.gz [root@blog ~]# rpm -qf /usr/bin/mpstat
sysstat-11.7.3-2.el8.x86_64

2,找不到mpstat命令时,可以用yum安装

[root@blog ~]# yum install sysstat

三,查看mpstat的版本和帮助

1,查看版本

[root@blog ~]# mpstat -V
sysstat version 11.7.3
(C) Sebastien Godard (sysstat <at> orange.fr)

2,查看帮助

[root@blog ~]# mpstat --help

四,常用的用法举例

1,查看所有cpu的运行情况

# -P 指定cpu的id,ALL表示所有cpu

[root@blog ~]# mpstat -P ALL
Linux 4.18.0-80.11.2.el8_0.x86_64 (blog) 04/08/2020 _x86_64_ (4 CPU)

03:43:05 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
03:43:05 PM all 0.03 0.00 0.02 0.00 0.00 0.00 0.00 0.00 0.00 99.95
03:43:05 PM 0 0.05 0.00 0.03 0.00 0.00 0.00 0.00 0.00 0.00 99.92
03:43:05 PM 1 0.02 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 99.97
03:43:05 PM 2 0.04 0.00 0.02 0.00 0.00 0.00 0.00 0.00 0.00 99.94
03:43:05 PM 3 0.02 0.00 0.02 0.00 0.00 0.00 0.00 0.00 0.00 99.96 

2,查看指定cpu的运行情况

## -P 指定cpu的id,此处是1

[root@blog ~]# mpstat -P 1
Linux 4.18.0-80.11.2.el8_0.x86_64 (blog) 04/08/2020 _x86_64_ (4 CPU) 03:55:12 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
03:55:12 PM 1 0.02 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 99.97

3,指定输出的时间间隔和次数

#命令格式:mpstat [-P {|ALL}] [internal [count]]

#internal  时间间隔,此处值是3

#count     统计次数,此处值是5

# 显示所有cpu的统计信息,每隔3秒统计一次,共统计5次后退出

[root@blog ~]# mpstat -P ALL 3 5 

说明:

当没有参数时,mpstat则显示系统启动以后所有信息的平均值。

有interval时,第一行的信息自系统启动以来的平均信息。

从第二行开始,输出为前一个interval时间段的平均信息。

五,输出信息各字段的含义:

user(通常缩写为 us),代表用户态 CPU 时间。

注意,它不包括下面的 nice 时间,但包括了 guest 时间。

nice(通常缩写为 ni),代表低优先级用户态 CPU 时间,也就是进程的 nice 值被调整为 1-19 之间时的 CPU 时间。

注意,nice 可取值范围是 -20 到 19,数值越大,优先级反而越低。

system(通常缩写为 sys),代表内核态 CPU 时间。

idle(通常缩写为 id),代表空闲时间。

注意,它不包括等待 I/O 的时间(iowait)。

iowait(通常缩写为 wa),代表等待 I/O 的 CPU 时间。

irq(通常缩写为 hi),代表处理硬中断的 CPU 时间。

softirq(通常缩写为 si),代表处理软中断的 CPU 时间。

steal(通常缩写为 st),代表当系统运行在虚拟机中的时候,被其他虚拟机占用的 CPU 时间。

guest(通常缩写为 guest),代表通过虚拟化运行其他操作系统的时间,也就是运行虚拟机的 CPU 时间。

guest_nice(通常缩写为 gnice),代表以低优先级运行虚拟机的时间。

六,查看centos版本

[root@blog ~]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)

centos8平台使用mpstat监控cpu的更多相关文章

  1. centos8平台使用pidstat监控cpu/内存/io

    一,安装pidstat: 1,安装 [root@localhost yum.repos.d]# yum install sysstat 2,查看版本: [root@localhost ~]# pids ...

  2. centos8平台使用iostat监控磁盘io

    一,iostat所属的包: [root@centos8 ~]# whereis iostat iostat: /usr/bin/iostat /usr/share/man/man1/iostat.1. ...

  3. centos8平台使用iotop监控磁盘io

    一,iotop的作用: iotop是监视磁盘I/O使用状况的top类工具, 可以针对进程和线程统计io的使用情况 说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblog ...

  4. centos8平台基于iftop监控网络流量

    一,iftop的作用: 基于ip统计外部机器与本机之间的网络流量, 可以方便的查看各客户端是否有非正常的到本机的访问 说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnbl ...

  5. centos8平台使用vmstat监控系统

    一,vmstat的用途和特点: vmstat 是一个常用的系统性能分析工具,主要用来分析系统的内存使用情况,也常用来分析 CPU 上下文切换和中断的次数. 相对于 iostat 来说,vmstat 可 ...

  6. centos8平台用ss监控网络

    一,ss所属的包: [root@blog ~]# whereis ss ss: /usr/sbin/ss /usr/share/man/man8/ss.8.gz [root@blog ~]# rpm ...

  7. centos8平台使用lscpu查看cpu信息

    一,lscpu所属的包: [root@yjweb ~]# whereis lscpu lscpu: /usr/bin/lscpu /usr/share/man/man1/lscpu.1.gz [roo ...

  8. centos8平台使用slabtop监控slab内存的状态

    一,slabtop 所属的包: [root@yjweb ~]# whereis slabtop slabtop: /usr/bin/slabtop /usr/share/man/man1/slabto ...

  9. 第一个python实例--监控cpu

    #第一个python实例:监控cpu #/bin/bash/env Python from __future__ import print_function from collections impo ...

随机推荐

  1. pthon中取整的几个方法round、int、math

    取整的几种方法:1.四舍五入 round(x) 2.向下取整  int(x) 3.取商和余 4.向上取整,需要用到math.ceil(x)(可以理解成大于x且最接近x的整数)import math 5 ...

  2. 恭喜!Apache Hudi社区新晋多位Committer

    1. 介绍 经过Apache Hudi项目委员会讨论及投票,向Udit Mehrotra.Gary Li.Raymond Xu.Pratyaksh Sharma 4人发出Committer邀请,4人均 ...

  3. ctfhub 报错注入

    payload   1 Union select count(*),concat((查询语句),0x26,floor(rand(0)*2))x from information_schema.colu ...

  4. FreeSWITCH 处理Refer盲转时,UUI传递不对(没有将SIP 消息头Refer-To中的User-to-User传递给B-Leg)

    运行环境:     CentOS 7.6     FreeSWICH 1.6.18   一.问题场景:     FreeSWITCH收到REFER命令后,重新发起的INVITE消息中的 "U ...

  5. 《zookeeper原理与实践》笔记

    第1章 分布式架构 1.1 分布式 分布式特点:分布性.对等性.并发性.缺乏全局时钟.故障总是会发生. 分布式问题:通讯异常.网络分区(脑裂).三态.节点故障.   1.2 ACID到CAP/BASE ...

  6. vulnhub-Os-hackNos-3

    vulnhub-Os-hackNos-3 nmap 192.168.114.0/24 查看存活主机,发现192.168.114.142. 具体探究: 发现80和22端口是开放的. dirb没扫出来啥, ...

  7. xss利用——BeEF#stage4(其余功能介绍)

    目录 信息收集 => 社会工程 =>网络扫描 => 结合metasploit => tunneling => xss => 维持权限 功能介绍 #1 - 信息收集 ...

  8. 提权 EXP

    windows: 漏洞列表 #Security Bulletin #KB #Description #Operating System CVE-2017-0213 [Windows COM Eleva ...

  9. 什么是垃圾搜集(GC)?为什么要有GC呢?

    GC的全称是Gabage Collection,翻译过来就是"垃圾收集"的意思.那么我们为什么用GC呢? 那么我们接下来就来聊一聊GC的创造背景.在C和C++那个年代的程序员界的长 ...

  10. java进阶(23)--List接口

    一.基本概念 1.有序可重复 2.有下标 3.包含ArraList.LinkedList.Vector   二.List中特有的方法 且常用 (以下军均为数组通用方法) 1.void add(int ...