惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
量子位
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
D
DataBreaches.Net
B
Blog
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
H
Help Net Security
The Cloudflare Blog
U
Unit 42

轶哥博客

blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog
blog
2020-11-06 · via 轶哥博客

遇到一个奇怪的需求,需要在项目未正式交付前,各台服务器使用率满足“CPU不低于 20% ,内存不低于40%,磁盘不低于40%”的要求。

CPU使用率

下载负载生成程序

使用方法

例1:所有CPU核心负载30%运行10秒钟

./cpu -p 30 -t 10

例2:所有CPU核心负载30%持续运行

./cpu -p 30

例3:只让2个CPU核心负载30%运行10秒钟

./cpu -p 30 -c 2 -t 10
  • all CPU load = (num of para c _ num of p) / (all cores count of CPU _ 100)
  • may not specify cores run the load only, it just promise the all CPU load, and not promise each cores run the same load

例4:后台运行,CPU使用率不低于20%

nohup ./cpu -p 21 >> cpu.log 2>&1 &

参数说明

--coresCount value, -c value   使用多少核心 (可选, 默认: 8)

--timeSeconds value, -t value  运行多长时间 (可选, 默认: 2147483647)

--percentage value, -p value   每个核心的负载百分比 (必须)

--help, -h                     显示帮助信息

内存使用率

下载内存泄露程序

下载地址一:http://todo.sercretcore.cn/memory.zip

下载地址二:https://cdn.wyr.me/files/memory.zip

使用方法

例1:快速进行内存泄露至2GB

$ ./memory -d 5 -l 2048
Leaked: 2048 MiB ███████▒▒▒ 
Holding at 2048 MiB 

例2:后台运行内存泄露至13GB

nohup ./memory -l 13312 >> memory.log 2>&1 &

参数说明

./memory [-d <泄露延迟 ms; 默认 100>]
 
  -d int    选项: 调整泄漏率的延迟(毫秒); 默认 100ms

  -l int    选项: 内存泄漏上限 (MiB); 默认无上限

硬盘占用

进入到需要生成占用文件的目录,使用dd命令生成对应大小文件。

dd if=/dev/zero of=data bs=1M count=1024

上述命令将生成1G大小的名为data的文件。修改1024调整生成文件的大小。

更多

希望以后不要再遇到这种需求。

使用到的开源项目,感谢原作者的付出