Artificially modify server load in Ubuntu Artificially modify server load in Ubuntu linux linux

Artificially modify server load in Ubuntu


One of the most important things to know about Linux (or Unix) systems is, everything is just a file. Since you are just reading from /proc/loadavg, the easiest was for you to accomplish what you are after is simply make a text file that contains a line of text that you would see when running cat /proc/loadavg. Then have your program read from that file you created instead of /proc/loadavg and it will be none the wiser. If you want to test under different "artificial" situations, just change the text in this file and save. When your testing is done, simply change your program back to reading from /proc/loadavg and you can be sure it will work as expected.

Note, you can make this text file anywhere you want...in your home directory, in the program directory, wherever. However, you shouldn't make it in /proc. That directory is reserved for system objects.


You can use the stress command, see http://weather.ou.edu/~apw/projects/stress/

A tool to impose load on and stress test a computer system

sudo apt-get install stress

To avoid CPU warm, you can install a virtual machine with small cpu capacity. virtualbox and qemu-kvm are free.


Use chroot to run the various pieces of software you're testing with a specified directory as the root directory. Set up a manufactured/modified /proc/loadavg relative to that new root directory, too.

chroot will let you create a dummy file that appears to have /proc/loadavg as its path, so the software will observe your manufactured values even if you can't change your code to look for load data in a different location.