1:安装stress-ng
[root@kolla ~]# yum install stress-ng
[root@kolla ~]# rpm -qa |grep stress
stress-ng-0.07.29-2.el7.x86_64
2:指定cpu进行压测
taskset -c 2 stress-ng --cpu 1 --cpu-load 70 --timeout 20h
taskset:指定使用哪个cpu
--cpus:开启几个线程
--cpu-load:指定cpu的压测负载
--timeout:压测时间
3:top查看系统cpu使用率
top命令查看:
top - 17:23:17 up 4 days, 23:44, 3 users, load average: 0.32, 0.41, 0.55
Tasks: 157 total, 2 running, 155 sleeping, 0 stopped, 0 zombie
%Cpu(s): 8.9 us, 0.0 sy, 0.0 ni, 91.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 16265380 total, 12369264 free, 673684 used, 3222432 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 13155812 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
20292 root 20 0 56984 6276 1228 R 71.1 0.0 0:21.33 stress-ng-cpu
1 root 20 0 191164 4248 2652 S 0.0 0.0 0:36.13 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.06 kthreadd
4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
5 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u16:0
6 root 20 0 0 0 0 S 0.0 0.0 0:00.25 ksoftirqd/0
4:mpstat查看结果如下
[root@kolla ~]# mpstat -P ALL 5
Linux 3.10.0-1062.1.1.el7.x86_64 (kolla) 11/11/2021 _x86_64_ (8 CPU)
05:24:09 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
05:24:14 PM all 8.65 0.00 0.05 0.00 0.00 0.00 0.00 0.00 0.00 91.30
05:24:14 PM 0 0.20 0.00 0.20 0.00 0.00 0.00 0.00 0.00 0.00 99.60
05:24:14 PM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:24:14 PM 2 68.74 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 31.26
05:24:14 PM 3 0.00 0.00 0.20 0.00 0.00 0.00 0.00 0.00 0.00 99.80
05:24:14 PM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:24:14 PM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:24:14 PM 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:24:14 PM 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:24:14 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
05:24:19 PM all 8.90 0.00 0.03 0.00 0.00 0.00 0.00 0.00 0.00 91.07
05:24:19 PM 0 0.20 0.00 0.20 0.00 0.00 0.00 0.00 0.00 0.00 99.60
05:24:19 PM 1 0.20 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.80
05:24:19 PM 2 70.74 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 29.26
05:24:19 PM 3 0.20 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.80
05:24:19 PM 4 0.20 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.80
05:24:19 PM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:24:19 PM 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:24:19 PM 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
|