11

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 http://kernel.ubuntu.com/~cking/stress-ng/ 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%

enter image description here

Any ideas how to achieve this?

AJN
  • 406
  • 1
  • 4
  • 13

2 Answers2

22

I designed stress-ng so that one can specify 0 for the number of stressor processes to match the number of on-line CPUs, so to load each cpu at say 40%, use

stress-ng -c 0 -l 40

Colin Ian King
  • 336
  • 1
  • 3
5

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

enter image description here

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

    stress-ng -c 4 -l 80

enter image description here

AJN
  • 406
  • 1
  • 4
  • 13