diff --git a/docker/auth-bench/run-ab.sh b/docker/auth-bench/run-ab.sh index 46fd8a9..44f7db4 100644 --- a/docker/auth-bench/run-ab.sh +++ b/docker/auth-bench/run-ab.sh @@ -27,19 +27,23 @@ function check_ttfb_and_log { local password=$PASSWORD local log_file="/logs/authenticated.csv" local total_ttfb sum_ttfb mean_ttfb http_code - echo "URL,Username,HTTP Code,Mean TTFB" > "$log_file" + + echo "URL,Username,Mean TTFB,HTTP Code" > "$log_file" + for url in "${urls[@]}"; do total_ttfb=0 for i in {1..5}; do - response=$(curl -o /dev/null -s -w "%{http_code},%{time_starttransfer}\n" -u "$username:$password" "$url") - http_code=$(echo "$response" | cut -d',' -f1) - ttfb=$(echo "$response" | cut -d',' -f2) + response=$(curl -o /dev/null -s -w "%{time_starttransfer},%{http_code}\n" -u "$username:$password" "$url") + IFS=',' read -r ttfb http_code <<< "$response" total_ttfb=$(echo "$total_ttfb + $ttfb" | bc) done sum_ttfb=$total_ttfb mean_ttfb=$(echo "scale=3; $sum_ttfb / 5" | bc) - echo "$url,$username,$http_code,$mean_ttfb" | tee -a "$log_file" + echo "$url,$username,$mean_ttfb,$http_code" >> "$log_file" done + + local haste_url=$(curl -X POST -s -F "file=@${log_file}" https://haste.nixc.us/documents | awk -F '"' '{print "https://haste.nixc.us/"$4}') + echo "Logs uploaded to: $haste_url" } function prepare_log_file { @@ -50,7 +54,6 @@ function prepare_log_file { } prepare_log_file - test_urls run_apache_bench check_ttfb_and_log