Sunday, June 30, 2013

Simple UNIX Shell Script for generating disk IO trafic

Here is pretty easy unix shell script for disk I/O generation.
#!/bin/sh
dd_threads="0 1 2 3 4 5 6 7 8 9"
finish () {
  killall dd
  for i in $dd_threads
  do
    rm /var/tmp/dd.$i.test
  done
  exit 0;
}
trap 'finish' INT
while true
do
  for i in $dd_threads
  do
    dd if=/dev/random of=/var/tmp/dd.$i.test bs=512 count=100000 &
  done
done
Generated IOs (aka TPS - transaction per second) can be watched by following command
iostat -d -c 100000
Script can be terminated by pressing CTRL-C.

No comments: