summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNullspoon <nullspoon@iohq.net>2014-02-23 14:31:46 -0700
committerNullspoon <nullspoon@iohq.net>2014-02-23 14:31:46 -0700
commit09cb98ce3fdff4384db8d06fe9db89fc14b6d616 (patch)
tree4275f57ceb66a7aaf74529d11ae02a4c938923c3
parent5f2be53e1215f2baff09e51d4703e4512a95e19a (diff)
downloadforkload-09cb98ce3fdff4384db8d06fe9db89fc14b6d616.tar.gz
forkload-09cb98ce3fdff4384db8d06fe9db89fc14b6d616.tar.xz
Initial commit of the script
Currently supports specifying number of clients to call pages (default 1), custom destination (duh), and a custom output file (default forkload.out). Still need to write the help text function
-rw-r--r--.gitignore1
-rwxr-xr-xforkload47
2 files changed, 48 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f47cb20
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.out
diff --git a/forkload b/forkload
new file mode 100755
index 0000000..93f22f3
--- /dev/null
+++ b/forkload
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+
+function get_help {
+ echo "This needs to be written"
+}
+
+function main {
+ argv=(${@})
+
+ out="forkload.out"
+ clients=1
+ dest=""
+
+ # Parse arguments
+ for (( i = 0; i < ${#argv[*]}; i++ )); do
+ val=${argv[$i]}
+ if [[ ${val} == "-o" || ${val} == "--output" ]]; then
+ i=$((i+1))
+ out=${argv[$i]}
+ elif [[ ${val} == "-c" || ${val} == "--clients" ]]; then
+ i=$((i+1))
+ clients=${argv[$i]}
+ elif [[ ${val} == "-d" || ${val} == "--dest" ]]; then
+ i=$((i+1))
+ dest=${argv[$i]}
+ fi
+ done
+
+ # Verify needed variables
+ if [[ -z ${dest} ]]; then
+ echo -e "\nPlease specify a destination URL to test (-d,--dest)."
+ echo -e "See the help text (-h,--help) for more details.\n"
+ exit
+ fi
+
+
+ # Clean up the out file
+ :> ${out}
+
+ for (( i = 0; i < ${clients}; i++ )); do
+ echo "Client ${i}";
+ # Fork, time the page download
+ { ( time curl -s ${dest} > /dev/null & ) } 2>> ${out}
+ done
+}
+
+main "${@}"

Generated by cgit