lscpu
lscpu 查看和cpu配置相关的信息
[root@zcc ~]# lscpu
Architecture: x86_64 //架构--这里的64指的位处理器
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1 //cpu个数 1个
On-line CPU(s) list: 0
Thread(s) per core: 1 //每个核心的线程数
Core(s) per socket: 1 //每个插槽上有几个核心
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 79
Model name: Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
Stepping: 1
CPU MHz: 2500.032
BogoMIPS: 5000.06
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K //一级高速缓存 dcache 用来存储数据
L1i cache: 32K //一级高速缓存 icache 用来存储指令
L2 cache: 256K //二级缓存
L3 cache: 40960K //三级缓存
nproc
nproc查看cpu的个数
[root@zcc ~]# nproc
1
mpstat
mpstat 多cpu系统中,实时监控每个cpu的状态。测试过程中常用,在后台观察各cpu状态
语法参数
mpstat [-P {|ALL}] [internal [count]]
-P {|ALL}:表示监控哪个CPU,在[0,cpu个数-1]中取值;
internal:相邻的两次采样的间隔时间
count:采样的次数,count只能和delay一起使用
常用用法
#每隔2秒刷新一次,分别显示各个cpu的实时信息
mpstat -P ALL 2
#每隔1秒刷新一次,总共显示10次
mpstat 1 10
%user 在internal时间段里,用户态的CPU时间(%),不包含nice值为负进程 (usr/total)*100
%nice 在internal时间段里,nice值为负进程的CPU时间(%) (nice/total)*100
%sys 在internal时间段里,内核时间(%) (system/total)*100
%iowait 在internal时间段里,硬盘IO等待时间(%) (iowait/total)*100
%irq 在internal时间段里,硬中断时间(%) (irq/total)*100
%soft 在internal时间段里,软中断时间(%) (softirq/total)*100
%idle 在internal时间段里,CPU除去等待磁盘IO操作外的因为任何原因而空闲的时间闲置时间(%) (idle/total)*100
重点关注%idle(cpu空载时间),%iowait(硬盘IO等待时间)