TODO:如何模拟cpu打满,磁盘打满,网卡打满
背景:
测试活动中,需要构造cpu打满、磁盘打满、网卡打满的场景
场景1:cpu打满
环境信息:
虚拟机,物理核数16个,每个物理核的虚拟核数1个,虚拟核数16个:
[root@vm10-0-0-8 test_data]# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
16
[root@vm10-0-0-8 test_data]# cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores : 1
[root@vm10-0-0-8 test_data]# cat /proc/cpuinfo| grep "processor"| wc -l
16
top命令查看到当前cpu 占用率:
[root@vm10-0-0-8 test_data]# top
top - 21:20:02 up 16 days, 6:07, 6 users, load average: 10.29, 8.05, 3.80
Tasks: 198 total, 1 running, 197 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.1 sy, 0.0 ni, 99.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 32778624 total, 18760920 free, 701276 used, 13316428 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 31481428 avail Mem
%Cpu(s):
0.0 us,用户占用率(没有nice调度过)
0.1 sy,系统占用率
0.0 ni,用户空间通过nice调度过的程序cpu占用率
99.9 id,idle,空闲率
0.0 wa, 0.0 hi, 0.0 si, 0.0 st
构造cpu打满的场景:
[root@vm10-0-0-8 test_data]# cat while_1.sh
#!/bin/bash function while_1()
{ while ((1));
do
i=2;
done
} while_1 &
执行while_1.sh后,发现cpu中1个core被打满了:
[root@vm10-0-0-8 test_data]# sh while_1.sh
[root@vm10-0-0-8 test_data]#
[root@vm10-0-0-8 test_data]# ps -ef |grep while_1.sh
root 21553 1 99 21:29 pts/4 00:00:03 sh while_1.sh [root@vm10-0-0-8 test_data]# top
top - 21:29:54 up 16 days, 6:17, 6 users, load average: 1.17, 4.11, 3.58
Tasks: 196 total, 2 running, 194 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.5 us, 1.7 sy, 0.0 ni, 93.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 32778624 total, 18763900 free, 698328 used, 13316396 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 31484616 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
21553 root 20 0 113176 392 200 R 100.0 0.0 0:20.97 sh
将16个core都打满:
[root@vm10-0-0-8 test_data]# cat run_while.sh
#!/bin/bash function while_1()
{
while ((1));
do
i=2;
done
} function run_while()
{
for ((i=0; i<$1; i++));
do
while_1 &
done
} run_while $1
[root@vm10-0-0-8 test_data]# sh run_while.sh 16 (16是core的数,可自定义)
[root@vm10-0-0-8 test_data]# ps -ef |grep while
root 21751 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21752 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21753 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21754 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21755 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21756 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21757 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21758 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21759 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21760 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21761 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21762 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21763 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21764 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21765 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
root 21766 1 99 21:31 pts/4 00:00:55 sh run_while.sh 16
查看cpu占用清空,idle为零了:
[root@vm10-0-0-8 test_data]# top
top - 21:33:55 up 16 days, 6:21, 6 users, load average: 14.08, 7.45, 4.85
Tasks: 211 total, 17 running, 194 sleeping, 0 stopped, 0 zombie
%Cpu(s): 73.3 us, 26.7 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 32778624 total, 18758856 free, 702964 used, 13316804 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 31479616 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
21761 root 20 0 113176 388 196 R 100.0 0.0 2:05.13 sh
21751 root 20 0 113176 388 196 R 100.0 0.0 2:05.11 sh
21752 root 20 0 113176 388 196 R 100.0 0.0 2:05.13 sh
21753 root 20 0 113176 388 196 R 100.0 0.0 2:05.13 sh
21754 root 20 0 113176 388 196 R 100.0 0.0 2:05.12 sh
21756 root 20 0 113176 388 196 R 100.0 0.0 2:05.13 sh
21758 root 20 0 113176 388 196 R 100.0 0.0 2:05.13 sh
21759 root 20 0 113176 388 196 R 100.0 0.0 2:05.13 sh
21760 root 20 0 113176 388 196 R 100.0 0.0 2:05.13 sh
21762 root 20 0 113176 388 196 R 100.0 0.0 2:05.12 sh
21764 root 20 0 113176 388 192 R 100.0 0.0 2:05.10 sh
21766 root 20 0 113176 388 192 R 100.0 0.0 2:05.13 sh
21755 root 20 0 113176 388 196 R 100.0 0.0 2:05.11 sh
21757 root 20 0 113176 388 196 R 100.0 0.0 2:05.10 sh
21763 root 20 0 113176 388 192 R 100.0 0.0 2:05.11 sh
21765 root 20 0 113176 388 192 R 100.0 0.0 2:05.04 sh
TODO:如何模拟cpu打满,磁盘打满,网卡打满的更多相关文章
- MySQL ibdata1撑爆占满磁盘空间
MySQL主从由于ibdata1占满磁盘空间-->主从失效 因为设置了innodb_file_per_table = 1,ibdata1依旧撑爆占满磁盘空间 主从断的时候,IO线程在连接,SQL ...
- jenkins log文件突然占满磁盘空间
今天早上同事反应jenkins构建job发生异常,于是登录机器查看发现磁盘空间已满.进一步排查之后发现jenkins的catalina.out文件已占满磁盘空间. 用tail看了下日志后面都是关于DN ...
- python之psutil模块(获取系统性能信息(CPU,内存,磁盘,网络)
一.psutil模块 1. psutil是一个跨平台库(http://code.google.com/p/psutil/),能够轻松实现获取系统运行的进程和系统利用率(包括CPU.内存.磁盘.网络等) ...
- ubuntu16系统磁盘空间/dev/vda1占用满的问题
参考文档: https://www.cnblogs.com/moonandstar08/p/6091507.html (系统磁盘空间/dev/xvda1占满原因分析) https://blog.csd ...
- centos7-java模拟cpu占用高及排查
环境 centos7 1核2GB Java8 模拟cpu占用高 新建一个名为jvm-learn的springboot项目 模拟代码如下 import org.springframework.boot. ...
- WPF 动态模拟CPU 使用率曲线图
原文:WPF 动态模拟CPU 使用率曲线图 在工作中经常会遇到需要将一组数据绘制成曲线图的情况,最简单的方法是将数据导入Excel,然后使用绘图功能手动生成曲线图.但是如果基础数据频繁更改, ...
- CENTOS7-JAVA模拟CPU占用高及排查( 转)
环境 centos7 1核2GB Java8 模拟cpu占用高 新建一个名为jvm-learn的springboot项目 模拟代码如下 import org.springframework.boot. ...
- linux下模拟CPU占用100%小程序
在做一个测试时,需要模拟服务器CPU占用满的情况,在查阅相关资料后,发现网上程序不太好用, 原文在这:http://www.2cto.com/os/201304/202068.html 优化后如下: ...
- windows系统c盘占满/linux系统磁盘block、inode占满处理
windows系统 下载c盘清理.bat到服务器,双击bat文件将自动清理 linux系统 先远程ssh登录上服务器,登录教程:http://www.west263.com/faq/list.asp? ...
随机推荐
- SpringBoot从1.5.1→2.2.4项目加包扫雷三:org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter已过时
@Configuration@Slf4j@PropertySource({"classpath:/config.properties"})public class MyWebApp ...
- defender 书荐
2018全年度推荐: 1.[法]大仲马——基督山伯爵 2.[美]加西亚·马尔克斯——百年孤独 3.[法]大仲马——三个火枪手 2019第一季度推荐: 1.霍达——穆斯林的葬礼 2.[苏联]尼·奥斯特洛 ...
- 将IMAGE转为PDF后上传
using iTextSharp.text; using iTextSharp.text.pdf; /// <summary> /// 将IMAGE转为PDF后上传 /// </su ...
- win10子系统ubuntu忘记密码解决方案
准备部署一个rocket.chat 需要安装mongodb 3.6 准备直接在子系统中安装一下,结果忘记ROOT密码了 找了一下子系统重置密码 记录如下 ubuntu config --defau ...
- [PAT] A1018 Public Bike Management
[思路] 题目生词 figure n. 数字 v. 认为,认定:计算:是……重要部分 The stations are represented by vertices and the roads co ...
- 小希的迷宫 HDU - 1272
#include<iostream> #include<algorithm> #include<cstring> using namespace std; cons ...
- vsftpd最详细的配置文件
vsftpd作为一个主打安全的FTP服务器,有很多的选项设置.下面介绍了vsftpd的配置文件列表,而所有的配置都是基于vsftpd.conf这个配置文件的.本文将提供完整的vsftpd.conf的中 ...
- div中宽高度自适应文字换行居中问题解决
<html> <head> <meta charset="UTF-8"/> <title>div中宽高度自适应文字换行居中demo& ...
- CTF中压缩文件的常见解法
此篇记录两篇记录的比较好的关于压缩文件破解的总结 链接:https://blog.csdn.net/xuqi7/article/details/71437882 https://blog.csdn.n ...
- base(根URL)
指定用于一个文档中包含的所有相对 URL 的根 URL.一份中只能有一个 <base> 元素. 可以通过使用 document.baseURI 的 JS 脚本查询 属性 包含全局属性 hr ...