How to Impose High CPU Load and Stress Test on Linux Using 'Stress-ng' Tool - Part 2
Abstract: use the –cpu N option as follows. To use a given CPU stress testing methoduse –vm-bytes N option. To stop vm stress processes after N bogo operations
To install stress-ng, run the following command.
$ sudo apt-get install stress-ng [on Debian based systems] # yum install stress-ng [on RedHat based systems]
The general syntax for using stress-ng is:
$ sudo stress-ng option argument
Some of the options that you can use with stress-ng:
- To start N instances of each stress test, use the –all N option as follows.
- To start N processes to exercises the CPU by sequentially working through all the different CPU stress testing methods, use the –cpu N option as follows.
- To use a given CPU stress testing method, use –cpu-method option. There are many methods available that you can use, to view the manpage to see all the methods to use.
- To stop CPU stress process after N bogo operations, use the –cpu-ops N option.
- To start N I/O stress testing processes, use the –io N option.
- To stop io stress processes after N bogo operations, use the –io-ops N option.
- To start N vm stress testing processes, use the –vm N option.
- To specify amount of memory per vm process, use –vm-bytes N option.
- To stop vm stress processes after N bogo operations, use –vm-ops N options
- Use the –hdd N option to start N harddisk exercising processes.
- To stop hdd stress processes after N bogo operations, use –hdd-ops N option.
- You can set a timeout after N seconds by using the –timeout N option.
- To generate a summary report after bogo operations, you can use –metrics or –metrics-brief options. The –metrics-brief displays non zero metrics.
- You can also start N processes that will create and remove directories using mkdir and rmdir by using the –dir N option.
- To stop directory operations processes use –dir-ops N options.
- To start N CPU consuming processes that will exercise the present nice levels, include the
- –nice N option. When using this option, every iteration will fork off a child process that runs through all the different nice levels running a busy loop for 0.1 seconds per level and then exits.
- To stop nice loops, use the –nice-ops N option as follows.
- To start N processes that change the file mode bits via chmod(2) and fchmod(2) on the same file, use the –chmod N option. Remember the greater the value for N then the more contention on the file. The stressor will work through all the combination of mode bits that you specify with chmod(2).
- You can stop chmod operations by the –chmod-ops N option.
- You can use the -v option to display more information about ongoing operations.
- Use -h to view help for stress-ng.
1. To run 8 CPU stressors with a timeout of 60 seconds and a summary at the end of operations.
[email protected]:~$ uptime [email protected]:~$ sudo stress-ng --cpu 8 --timeout 60 --metrics-brief [email protected]:~$ uptimeSample Output
[email protected]:~$ uptime 18:15:29 up 12 min, 1 user, load average: 0.00, 0.01, 0.03 [<-- Watch Load Average] [email protected]:~$ sudo stress-ng --cpu 8 --timeout 60 --metrics-brief stress-ng: info: [1247] dispatching hogs: 8 cpu stress-ng: info: [1247] successful run completed in 60.42s stress-ng: info: [1247] stressor bogo ops real time usr time sys time bogo ops/s bogo ops/s stress-ng: info: [1247] (secs) (secs) (secs) (real time) (usr+sys time) stress-ng: info: [1247] cpu 11835 60.32 59.75 0.05 196.20 197.91 [email protected]:~$ uptime 18:16:47 up 13 min, 1 user, load average: 4.75, 1.47, 0.54 [<-- Watch Load Average]
2. To run 4 FFT CPU stressors with a timeout of 2 minutes.
[email protected]:~$ uptime [email protected]:~$ sudo stress-ng --cpu 4 --cpu-method fft --timeout 2m [email protected]:~$ uptimeSample Output
[email protected]:~$ uptime 18:25:26 up 22 min, 1 user, load average: 0.00, 0.26, 0.31 [<-- Watch Load Average] [email protected]:~$ sudo stress-ng --cpu 4 --cpu-method fft --timeout 2m stress-ng: info: [1281] dispatching hogs: 4 cpu stress-ng: info: [1281] successful run completed in 120.01s [email protected]:~$ uptime 18:27:31 up 24 min, 1 user, load average: 3.21, 1.49, 0.76 [<-- Watch Load Average]
3. To run 5 hdd stressors and stop after 100000 bogo operations, run this command.
[email protected]:~$ uptime [email protected]:~$ sudo stress-ng --hdd 5 --hdd-ops 100000 [email protected]:~$ uptimeSample Output
[email protected]:~$ uptime 18:29:32 up 26 min, 1 user, load average: 0.43, 1.00, 0.67 [<-- Watch Load Average] [email protected]:~$ sudo stress-ng --hdd 5 --hdd-ops 100000 stress-ng: info: [1290] defaulting to a 86400 second run per stressor stress-ng: info: [1290] dispatching hogs: 5 hdd stress-ng: info: [1290] successful run completed in 136.16s [email protected]:~$ uptime 18:31:56 up 29 min, 1 user, load average: 4.24, 2.49, 1.28 [<-- Watch Load Average]
4. To run 8 CPU stressors, 4 I/O stressors and 1 virtual memory stressor using 1GB of virtual memory for one minute, run this command below.
[email protected]:~$ uptime [email protected]:~$ sudo stress-ng --cpu 4 --io 4 --vm 1 --vm-bytes 1G --timeout 60s --metrics-brief [email protected]:~$ uptimeSample Output
[email protected]:~$ uptime 18:34:18 up 31 min, 1 user, load average: 0.41, 1.56, 1.10 [<-- Watch Load Average] [email protected]:~$ sudo stress-ng --cpu 4 --io 4 --vm 1 --vm-bytes 1G --timeout 60s --metrics-brief stress-ng: info: [1304] dispatching hogs: 4 cpu, 4 iosync, 1 vm stress-ng: info: [1304] successful run completed in 60.12s stress-ng: info: [1304] stressor bogo ops real time usr time sys time bogo ops/s bogo ops/s stress-ng: info: [1304] (secs) (secs) (secs) (real time) (usr+sys time) stress-ng: info: [1304] cpu 1501 60.07 2.67 10.39 24.99 114.93 stress-ng: info: [1304] iosync 381463 60.01 0.00 12.90 6357.10 29570.78 [email protected]:~$ uptime 18:35:36 up 32 min, 1 user, load average: 4.66, 2.80, 1.59 [<-- Watch Load Average]Summary
As recommended, these tools should be used with superuser privileges as they have certain effects on the system. These tools are good for general System Administration in Linux. I hope this guide was useful and if you have any additional ideas on how to test the health status of your system using these tools or any other tools, do not hesitate to post a comment. Always stay connected to Tecmint, learn and share ideas for the benefit of open source.
Pages: 1 2