Topics

Archives

Handy References


« | Main | »

Random ranging…

By Matt | October 30, 2009

This was an attempt to provide random urls to http_load, which didn’t work since http_load just reads the file once. Looks like I may have delve into C and implement the randomness in http_load itself.

But I like the code. It takes the square root of the highest possible number in the file name to set a limit for $RANDOM.

square=$(echo "sqrt($file_choices)" | bc)
load_pid_wait_list=""
for (( q=1; q<=$tests; q++ ))
do
(while [[ 1 -lt 2 ]]
do
let R=$RANDOM%$square
let P=$RANDOM%$square
filenum=$(echo "$P * $R" | bc)
echo "http://192.168.7.148:9101/raid1/"$file_size"_File_"$filenum > "./http_load_urls_"$q
echo "http://192.168.8.148:9101/raid2/"$file_size"_File_"$filenum >> "./http_load_urls_"$q
done
)&
load_pid_wait_list="$load_pid_wait_list $!"
done
Later on in the script, these processes are killed:
for pid in $load_pid_wait_list
    do
      kill -9 $pid
    done

Topics: Uncategorized | No Comments »

Comments

You must be logged in to post a comment.