blob: 93f22f31d84ce0f31c7f032423a6a27cbd033660 (
plain)
1 #!/usr/bin/env bash
2
3 function get_help {
4 echo "This needs to be written"
5 }
6
7 function main {
8 argv=(${@})
9
10 out="forkload.out"
11 clients=1
12 dest=""
13
14 # Parse arguments
15 for (( i = 0; i < ${#argv[*]}; i++ )); do
16 val=${argv[$i]}
17 if [[ ${val} == "-o" || ${val} == "--output" ]]; then
18 i=$((i+1))
19 out=${argv[$i]}
20 elif [[ ${val} == "-c" || ${val} == "--clients" ]]; then
21 i=$((i+1))
22 clients=${argv[$i]}
23 elif [[ ${val} == "-d" || ${val} == "--dest" ]]; then
24 i=$((i+1))
25 dest=${argv[$i]}
26 fi
27 done
28
29 # Verify needed variables
30 if [[ -z ${dest} ]]; then
31 echo -e "\nPlease specify a destination URL to test (-d,--dest)."
32 echo -e "See the help text (-h,--help) for more details.\n"
33 exit
34 fi
35
36
37 # Clean up the out file
38 :> ${out}
39
40 for (( i = 0; i < ${clients}; i++ )); do
41 echo "Client ${i}";
42 # Fork, time the page download
43 { ( time curl -s ${dest} > /dev/null & ) } 2>> ${out}
44 done
45 }
46
47 main "${@}"
|