大网数据广告活动
服务器运维问答

stress-ng: Simulate specific cpu percentages

· 52CE 我爱测

Linux environment: Debian, Ubuntu, Centos Goal: Test monitoring program that set alarms and trigger different alarms at different cpu percentages. ex: (30-50%), (51-70%) and >90% So I need a cpu stresser that can simulate specifi…

问题原文

原帖链接 · AJN · CC BY-SA 4.0

Linux environment: Debian, Ubuntu, Centos

Goal:
Test monitoring program that set alarms and trigger different alarms at different cpu percentages.
ex: (30-50%), (51-70%) and >90%

So I need a cpu stresser that can simulate specific cpu percentage per core.
stress-mg looks like the most advanced.

According to its documentation https://manpages.ubuntu.com/manpages/man1/stress-ng.1.html it is possible to set load values between 0 and 100%:

-l P --cpu-load P load CPU by P %, 0=sleep, 100=full load (see -c)

stress-ng -c 1 -p 30

stress-ng: info: [12650] dispatching hogs: 0 I/O-Sync, 1 CPU, 0 VM-mmap, 0 HDD-Write, 0 Fork, 0 Context-switch, 30 Pipe, 0 Cache, 0 Socket, 0 Yield, 0 Fallocate, 0 Flock, 0 Affinity, 0 Timer, 0 Dentry, 0 Urandom, 0 Float, 0 Int, 0 Semaphore, 0 Open, 0 SigQueue, 0 Poll

Undesired result:
But it doesn't seem to work, ALL cores are hogged at 100%

Any ideas how to achieve this?

社区高分解答

原帖链接 · AJN · CC BY-SA 4.0

I should have used -l option

  1. Looks like -c 1 distribute the load between all cores. Not exactly 80/4 per core, I guess because the host already runing some stuff.

    stress-ng -c 1 -l 80

  1. and -c 4 simulate the load on each core

    stress-ng -c 4 -l 80

For more about stress-ng: assembly_stress-testing-real-time-systems-with-stress-ng_optimizing-rhel8-for-real-time-for-low-latency-operation

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。