In writing LoadAvg 2.0 we found we would often have a need to create load on our virtual machines for the different operating systems we support. While there are many ‘generic’ ways to do this – such as wild while and do loops, we found a great little script called CPU_load that provides a easy and elegant solution.

CPU_load is a  free script for stress testing linux servers, you can download it here. It relies on the ‘stress’ and ‘cpulimit’ packages which are also freely available.

To install the additional packages on Ubuntu you can simply type in:

– sudo apt-get install stress
– sudo apt-get install cpulimit

To install the additional packages on Redhat* or Fedora you can simply type in:

– sudo yum install stress
– sudo yum install cpulimit

*Note For Redhat 5 and 6 Servers you will need to Install REMI repository first before you can install the modules above. This only takes a few steps, and there is a complete and easy to follow guide located at rackspace here.

CPU_load

Once you have installed the packages and downloaded CPU_load its as easy to run as typing:

– ./cpuload.sh [cpu load in percent] [duration in seconds]

So to run a load of 25% on your server for 20 seconds you would type:

– ./cpuload.sh 25 20

Cpu_load then gives you a nice, interactive display so you can see whats happening, and a countdown is displayed in the terminal for you to follow. Here is a example of the output.

Screen Shot 2014-01-25 at 13.17.10

We hope you enjoy this great, free load testing tool as much as we do, and encourage you to support the developer, ajurge. View the project here.

https://github.com/ajurge/CPU_load

If you really want tohammer your cpu’s however, there is another great sript located here called CPU hammer

http://linux.cloudibee.com/2008/11/linux-cpu-hammer-script/

For a complete reference list of load testing frameworks you can follow these links:

http://www.ict4us.com/testtools/loadandperformancewikipedia.htm

http://www.opensourcetesting.org/performance.php