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? ...
随机推荐
- es的分布式架构原理是什么?
es的分布式架构原理是什么? 1.首先说一些分片(shard)是什么? ES中所有数据均衡的存储在集群中各个节点的分片中,会影响ES的性能.安全和稳定性 每个shard都是一个最小工作单元,承载部分数 ...
- HTML5中input新增类型+表单新增属性+其他标签属性
@ (猴头) Input 新增属性 email 邮箱(只在手机端有效) url 网址(只在iphone手机有效) tel 手机号(只在手机端有效) number 数字(右侧有上下按钮,只能输入 ...
- 牛客练习赛56 E 小雀和他的王国
题目链接:https://ac.nowcoder.com/acm/contest/3566/E 思路:tarjan缩点,桥重建图,dfs跑树的直径. #include <iostream> ...
- 剑指offer-面试题35-复杂链表的复制-链表
/* 题目: 实现一个函数,复制复杂链表,返回复制链表的头节点. */ /* 思路: 第一步,复制一个链表S‘,插在原链表S中. 第二步,链表S’复制链表S的random指针. 第三步:拆分链表S和S ...
- HTTP Status 404 – 未找到 spring mvc
HTTP Status 404 – 未找到 Type Status Report 消息 /houseSale//houseSaleController/houseSaleList 描述 源服务器未能找 ...
- [CF1311E] Construct the Binary Tree - 构造
Solution 预处理出 \(i\) 个点组成的二叉树的最大答案和最小答案 递归做,由于只需要构造一种方案,我们让左子树大小能小就小,因此每次从小到大枚举左子树的点数并检验,如果检验通过就选定之 现 ...
- 【学习笔记】:一天搞定HTML
PS:许多控制样式的标签在HTML5中都不推荐使用,建议使用CSS,如align,border等. 一.概念 HTML的英文全称:Hypertext Marked Language 超文本标记语言. ...
- CSS小记录
1.图片铺满 background: rgba(12, 100, 129, 1) url('https://images.cnblogs.com/cnblogs_com/yukarin/1639008 ...
- 专访|高思教育创始人须佶成(上)【UncleW】
大家好,我是校长运营圈专栏作者UncleW. 2017年9月,高思教育发布董事会公告,宣布完成5.5亿元人民币融资.成立于2009年的高思教育到今天刚刚8岁,员工人数已突破2000人,2017年共有5 ...
- 解决SourceTree每次拉取提交都需要输入密码的问题
打开终端并且输入: git config --global credential.helper osxkeychain 第一次需要输入密码,以后都不需要了