LSN #1 - Stress-ng to load test Linux

When setting up Linux monitoring, you may need to a way to spike CPU or put pressure on the hosts memory to test metrics and alerting. My use case was with Zabbix and having their agent installed in machines. Their Linux template comes with monitoring and triggers that can send alerts based on CPU, Memory and disk usage. Since its not normal for production application to hit these limits on a usual basis, stress-ng can help with testing. Below are some simple commands used.

CPU Stress Test

# spawns 4 worker threads to utilize 4 CPU cores. 
stress-ng --cpu 4 --cpu-load 95 --timeout 60s

# using --cpu 0 will figure out core count for you and fill it up
stress-ng --cpu 0 --cpu-load 95 --timeout 60s

Memory Stress Test

# creates one worker to use 90% of available RAM on vm for 60 seconds
stress-ng --vm 1 --vm-bytes 90% --timeout 60s

You can use stress-ng to also stress things like disk io (Read/Write operations). Also, the network interface can be stressed by creating networking traffic, but I haven't tested either of these.